千家信息网

centos6.3安装mysql5.7

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,1、查看CentOS自带MySQL 5.1组件并卸载rpm -qa | grep -i mysqlrpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_642、rpm
千家信息网最后更新 2025年02月03日centos6.3安装mysql5.7

1、查看CentOS自带MySQL 5.1组件并卸载

rpm -qa | grep -i mysql

rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64

2、rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm

rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm

3、rpm -ivh mysql-community-common-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-client-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm

4. 修改数据库编码。

为了保证数据库能正确处理中文,我们需要设定数据库默认的编码为utf8。修改/etc/my.cnf文件,并在其中加入以下内容:


[client]

default-character-set=utf8mb4

[mysqld]

character_set_server=utf8mb4

5、修改时区

6、启动MySQL

service mysqld start

6、mysql登录及修改密码

mysql -u root -p

7、在CentOS系统中防火墙默认是阻止3306端口的,现在开启3306端口

修改/etc/sysconfig/iptables 文件,添加以下内容:


查询防火墙状态:

[root@localhost ~]# service iptables status<回车>

停止防火墙:

[root@localhost ~]# service iptables stop <回车>

启动防火墙:

[root@localhost ~]# service iptables start <回车>

重启防火墙:

[root@localhost ~]# service iptables restart <回车>

永久关闭防火墙:

[root@localhost ~]# chkconfig iptables off<回车>

永久关闭后启用:

[root@localhost ~]# chkconfig iptables on<回车>

重启防火墙:

1)、重启后永久性生效:

开启:chkconfig iptables on

关闭:chkconfig iptables off

2)、即时生效,重启后失效:

开启:service iptables start

关闭:service iptables stop需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。

------------------------------------华丽分割线---------------------------------------

启动mysql的时候解决错误:Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

1、rm -rf /var/lib/mysql/

2、使用如下命令,重新初始化mysql

mysqld --initialize --user=mysql

3、service mysqld start

------------------------------------华丽分割线---------------------------------------

修改root密码报错解决:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) :表示没有生成root的临时密码

1、service mysqld stop 停掉mysql服务器

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

3、show databases;

use mysql;

show tables;

4、update user set authentication_string=PASSWORD('root123!@#') where user='root';

flush privileges;

exit;

------------------------------------华丽分割线---------------------------------------

解决错误:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

1、SET PASSWORD = PASSWORD('root123!@#');

2、flush privileges;

3、exit;


0