抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

1、检查是否已安装过mariadb,若有便删除(linux系统自带的)

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

2、检查是否已安装过mysql,若有便删除(linux系统自带的)

rpm -qa | grep mysql

3、检查mysql组和用户是否存在,如无创建:

cat /etc/group | grep mysql

cat /etc/passwd |grep mysql

创建用户和用户组

groupadd mysql

useradd -r -g mysql mysql

4、上传安装包到/usr/local下,解压并重命名

tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql

5、在mysql目录下创建data目录

mkdir /usr/local/mysql/data

6、修改拥有者为mysql用户

chown -R mysql:mysql /usr/local/mysql

7、mysql5.7.17过后没有默认的my.cnf。需要自行添加vi my.cnf(/etc目录下)

vi /etc/my.cnf

添加内容如下:

[client]
port = 3306
default-character-set=utf8

[mysqld]

# 一般配置选项

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character-set-server=utf8
default_storage_engine = InnoDB

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

如果需要MySQL不区分大小写,还需要添加(因为Windows下MySQL不区分,而Linux下区分)

lower_case_table_names=1

8、进入mysql/bin目录下编译安装并初始化mysql,记住命令行末尾的密码:

cd /usr/local/mysql/bin/

./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

比如密码:oWOytRp)q6h,

如果报错./mysqld :error while loading shared libraries: libaio.so.1; cannot open shared object file : No such file or directory
报错原因:系统需要安装libaio.so.1
下载:点击下载
安装:

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

9、执行启动命令

cd /usr/local/mysql
./support-files/mysql.server start

10、登录,进入mysql/bin目录下执行

./mysql -uroot -p

输入密码

Enter password: 输入第9步默认的临时密码

修改密码

set password=password("123456");

设置远程访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';

flush privileges;

向服务添加MySQL并且设置自启动

https://www.yangxufei.cn/2021/04/27/MySQL%E8%87%AA%E5%90%AF%E5%8A%A8/

验证:
123
新建数据库aio
123
导入aio.sql脚本