分类: Mysql/postgreSQL
2009-12-16 14:12:31
@ http://zcatt.cublog.cn
MySql
1) mysql_install_db program sets up the grant tables. If you install by RPM, it is runned automatically.
2) use mysqladmin to verify the server is running.
mysqladmin
version
mysqladmin
variables
mysqladmin
ping
mysqladmin
–u root shutdown
mysql_safe
–user=mysql –log &
mysqlshow
1) copy mysql.server to /etc/init.d, and rename as mysql. Make it executable
cp
mysql.server /etc/init.d/mysql
chmod
+x /etc/init.d/mysql
2) Set mysql service to run automatically at sys startup
chkconfig
--add mysql
or
chkconfig
--level 345 mysql on
3) Config /etc/my.cnf file
The sections are read by script in my.cnf, see the table.
Script |
Option Groups |
|
[mysqld], [server], [mysqld-major_version] |
|
[mysqld], [server], [mysqld_safe] |
|
[mysqld], [mysql.server], [server] |
4) if err, you can check the log files, host_name.err and host_name.log
tail
host_name.err
tail
host_name.log
2) The initial root passwd is empty. One root account is for localhost, one is for actual host name and IP number.
1) Two anonymous-user accounts are created initally without passwd initially.
mysql
-u root
SET
PASSWORD FOR ‘’@’localhost’ = PASSWORD(‘newpwd’);
SET
PASSWORD FOR ‘’@’host_name’ = PASSWORD(‘newpwd’);
or remove the anonymous users
mysql
-u root
DROP
USER ‘’;
2) The initial root passwd is empty. One root account is for localhost, one is for actual host name and IP number.
mysql
-u root
SET
PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘newpwd’);
SET
PASSWORD FOR ‘root’@’hostname’=PASSWORD(‘newpwd’);
or
mysqladmin
-u root password “newPwd”
mysqladmin
-u root -h host_name password “newpwd”
or
mysql
-u root
update
mysql.user set password=PASSWORD(‘newpwd’) where user =’root’;
flush
privileges;