更改目录权限和组
chmod 755 -R /usr/local/mysql/
chown mysql.mysql -R /usr/local/mysql/
启动mysql
/usr/local/mysql5/bin/mysqld_safe &
设置启动服务
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkdonfig --level 345 mysql on
修改登陆用户的密码
/usr/local/mysql5/bin/mysqladmin -u root password "root"
登陆mysql数据库
/usr/local/mysql5/bin/mysql -u root -p
Enter password: root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18 to server version: 5.0.19-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
mysql>delete from user where password=""; #删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
mysql>quit
附:mysql常见的一些有用的选项和命令
mysqld -----开启日志支持
--log
--log-update
--log-long-formart
mysql
grant all on database.* to user identified by "password" 新建一user用户,赋予其database数据库的所有权限
revoke all on database from user 移除user用户在database数据库上的所有权限
mysql -uroot -p --one-database databasename < file.sql 从file.sql文件导入sql语句到databasename这个数据库里