#
yum install -y mysql-devel
#
yum install -y mysql-server
#
yum install -y mysql
#
chgrp -R mysql /var/lib/mysql
#
chmod -R 770 /var/lib/mysql
#
service mysqld start
MySQL Daemon failed to start.
如果启动失败,可以用下面的命令,查看失败原因:
# less /var/log/mysqld.log
发现如下的错误提示:
InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB)
than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
修改配置文件中的值(640/64=10M)并查看修改结果:
#
vi /etc/my.cnf
innodb_data_file_path = ibdata1:10M:autoextend
# du -sm /var/lib/mysql/ibdata1
10 /var/lib/mysql/ibdata1
设置开机自启动,并查看设置结果:
#
chkconfig mysqld on
#
chkconfig mysqld --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
创建根用户密码,并登陆测试:
#
mysqladmin -u root password 123456 #//然后输入新密码,并确认一次
#
mysql -u root -p
忘记密码时,可用如下方法重置:
#
service mysqld stop
#
mysqld_safe --user=root --skip-grant-tables --skip-networking &
#
mysql -u root
mysql>
use mysql;
mysql>
update user set password=password("new_password") where user="root";
mysql>
flush privileges;
远程登陆的授权:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
远程登陆的授权成功后,可以用如下命令查看,如果有host为%的项,说明是OK的。
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *6C1C7AE8E372FE12E3DE2E22FE6C04CF8F6737DA |
| 127.0.0.1 | root | *6C1C7AE8E372FE12E3DE2E22FE6C04CF8F6737DA |
| ::1 | root | *6C1C7AE8E372FE12E3DE2E22FE6C04CF8F6737DA |
| localhost | | |
| % | root | *6C1C7AE8E372FE12E3DE2E22FE6C04CF8F6737DA |
+-----------+------+-------------------------------------------+
5 rows in set (0.00 sec)