centos6.4 安装mysql
centos彻底删除mysql
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否还有mysql软件:rpm -qa|grep mysql有的话继续删除
开始安装.....
有时候需要执行(yum clean all
yum makecache)
#yum update
#yum -y install mysql-server
#service mysqld start
mysql -u root -p
password:
MySQL>
#service mysqld stop
关闭mysql
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
MySQL> use mysql;
MySQL> UPDATE user SET Password=PASSWORD('root') where USER='root' and host='root' or host='localhost';//
MySQL> FLUSH PRIVILEGES;
#service mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
[root@etl01 bin]# chkconfig --list | grep -i iptables ====check fire wall
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@etl01 bin]# /sbin/service iptables stop ====stop fire wall
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: nat filter [ OK ]
Unloading iptables modules: [ OK ]
#service mysqld restart
安装完成后,常见问题解决整理:
1. 远程连接mysql数据库的时候,报错:出现 ERROR 1130 (HY000): Host '117.79.246.*'is not allowed to connect to this MySQL server提示信息,不能远程连接数据库。
解决方案如下:
这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'; //这个命令执行错误时,可能会报ERROR 1062 (23000): Duplicate entry '%-root' for key 1;这个错误,不用管它。
mysql>flush privileges;
mysql>select host, user from user;
2. 问题:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。前两天也出现过这个问题,网上找了一个比较流行的方法(见方法一),搞定了。今天又用这个试了试,却搞不定,在网上找了半天,终于发现是因为mysql数据库的user表里,存在用户名为空的账户即匿名账户,导致登录的时候是虽然用的是root,但实际是匿名登录的,通过错误提示里的''@'localhost'可以看出来,于是解决办法见方法二。
方法一:
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('jg448885') where USER='root';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q
方法二:
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q
方法三:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('jg448885’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
//查看防火墙是否已关闭.
3. mysql安装过程中出现错误 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
或者
# mysql -u root -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
现在终于找到解决方法了。本来准备重装的,现在不必了。
方法操作很简单,如下:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
mysql> FLUSH PRIVILEGES;
mysql> quit # /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
相关文章
- centos7利用yum安装lnmp的教程(linux+nginx+php7.1+mysql5.7)
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql+phpmyadmin
- CentOS7 linux下yum安装mysql5.7
- 在CentOS6.4上,安装MySQL5.6.14
- Centos6.4 YUM安装Mysql【整理】
- CentOS6.4 64位下安装mysql 5.6 步骤
- Centos6.4安装配置mysql
- Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置
- CentOS7使用yum在线安装mysql5.7
- CentOS7下安装MySQL5.7安装与配置(YUM)