cd /usr/local/mysql/
[iyunv@localhost mysql]#ls
bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share sql-bench support-files
#有bin等以上文件的话,恭喜你已经成功安装了mysql。
六、配置mysql5.5.37详细步骤
1
2
3
4
5
6
7
#把当前目录中所有文件的所有者设为root,所属组为mysql
chown -R root:mysql .
chown -R mysql:mysql data (可选)
#将mysql的启动服务添加到系统服务中
[iyunv@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
1
2
3
4
5
6
7
8
9
10
11
#mysql启动出错解决方法
1、问题
[iyunv@localhost mysql]# /etc/rc.d/init.d/mysql statusMySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED][iyunv@localhost mysql]# /etc/rc.d/init.d/mysql startStarting MySQL...The server quit without updating PID file(/usr/local/mysql/data/localhost.localdomain.pid). [FAILED]
2、原因
没有初始化权限表
3、解决办法
cd /usr/local/mysql(进入mysql安装目录)chown -R mysql.mysql .
#重新初始化数据库
[iyunv@B2C-test-server mysql]# ./scripts/mysql_install_db--user=mysql
[iyunv@B2C-test-server mysql]# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!
1
2
3
4
5
#直接输入mysql启动数据库出错:
[iyunv@localhost mysql]# mysql
-bash: mysql: command not found
#解决方法
[iyunv@localhost mysql]# ln -s /usr/local/mysql/bin/mysql/usr/bin/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#修改MySQL的root用户的密码以及打开远程连接
[iyunv@B2C-test-server mysql]# mysql -u root mysql
mysql> use mysql;
mysql> desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; #为root添加远程连接的能力
mysql> update user set Password = password('123456') where User='root'; #设置root用户密码
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
#重新登录
[iyunv@B2C-test-server mysql]# mysql -u root -p
Enter password:123456
#若还不能进行远程连接,关闭防火墙
[iyunv@B2C-test-server mysql]# /etc/rc.d/init.d/iptables stop
如下:
[iyunv@B2C-test-server mysql]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
skip-grant-tables
#重启mysql
/etc/init.d/mysqld restartStoppingmysqld:
[ OK ]Startingmysqld: [ OK ]
#无密码登录:
# mysql
mysql> use mysql;update user setPassword=Password('root') where User='root'; mysql> flush privileges;
#退出,修改/etc/my.conf,删除skip-grant-tables,重启mysql。搞定