当前位置:Gxlcms > 数据库问题 > CentOS6.8下使用yum安装mysql,并远程登陆mysql

CentOS6.8下使用yum安装mysql,并远程登陆mysql

时间:2021-07-01 10:21:17 帮助过:4人阅读

第10步、开放远程登录权限

使用修改表的方法:

修改mysql库的user表,将host项,从localhost改为%。%这里表示的是允许任意host访问,如果只允许某一个ip访问,则可改为相应的ip,比如可以将localhost改为192.168.1.123,这表示只允许局域网的192.168.1.123这个ip远程访问mysql。

mysql> use mysql;

mysql> update user set host = ‘%‘ where user = ‘root‘;

注:可能更新时报错,可跳过该步

mysql> select host, user from user;

mysql> flush privileges;

第11步、开放3306端口

输入命令:vim /etc/sysconfig/iptables
添加

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

 注意:state和dport前面是两个中横杠--。还有注意位置,放在80下面

技术分享
然后重启 防火墙:service iptables restart

第12步、设置开机启动(非必须),完。

chkconfig mysqld on

 


报错汇总

1 ,执行安装命令时报错

[root@vultr mysql-5.6.26-linux-glibc2.5-x86_64]# ./scripts/mysql_install_db --user=mysql

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file

原因:缺少安装包libaio和libaio-devel.
命令行#yum install libaio*

自动安装这两个包

 

2,安装设置root密码,但登录失败提示:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)?

#1.停止mysql数据库

/etc/init.d/mysqld stop

 

#2.执行如下命令

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

 

#不关闭窗口,另外开一个窗口执行下面步骤

#3.使用root登录mysql数据库

mysql -u root mysql

 

#4.更新root密码

mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘;

#最新版MySQL请采用如下SQL:

mysql> UPDATE user SET authentication_string=PASSWORD(‘newpassword‘) where USER=‘root‘;

 

#5.刷新权限

mysql> FLUSH PRIVILEGES;

 

#6.退出mysql

mysql> quit

 

#7.重启mysql

/etc/init.d/mysqld restart

 

#8.使用root用户重新登录mysql

mysql -u root -p

Enter password: <输入新设的密码newpassword>

维护方法

1,centos下完全卸载mysql

http://blog.csdn.net/rosten/article/details/25096159

CentOS6.8下使用yum安装mysql,并远程登陆mysql

标签:remove   远程   idt   stat   查看   system   nbsp   log   user   

人气教程排行