【mysql安装】linux服务器上安装mysql服务

1、安装准备

  • 到官网下载安装包

  • 上传到服务器某个位置

 

2、解压并移动解压包

[root@VM_16_2_centos ~]# tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

[root@VM_16_2_centos ~]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

 

3、在/usr/local/mysql目录下创建data目录,并授权

[root@VM_16_2_centos ~]# mkdir /usr/local/mysql/data

[root@VM_16_2_centos ~]# chmod -R 755 /usr/local/mysql

 

4、编译安装

[root@VM_16_2_centos ~]# cd /usr/local/mysql/bin

[root@VM_16_2_centos ~]# ./mysqld --initialize --user=root --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

  • 报错并解决

yum install  libaio-devel.x86_64

yum -y install numactl

 

5、运行初始化命令成功后,输出日志如下,一定要记住一下红色框密码

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

 

6、编辑配置文件my.cnf,添加配置如下

vim /etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8

 

7、测试启动mysql服务器

[root@VM_16_2_centos log]# /usr/local/mysql/support-files/mysql.server start

 

  • 报错,解决方法,添加目录和相应的文件

[root@VM_16_2_centos support-files]# cd /var/log/

[root@VM_16_2_centos log]# mkdir mariadb

[root@VM_16_2_centos log]# echo "" > /var/log/mariadb/mariadb.log

  • 再次启动成功

[root@VM_16_2_centos log]# /usr/local/mysql/support-files/mysql.server start

Starting MySQL. SUCCESS!

 

8、添加软连接,并重启mysql服务

[root@VM_16_2_centos log]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

[root@VM_16_2_centos log]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

[root@VM_16_2_centos log]# service mysql restart

Shutting down MySQL.. SUCCESS!

Starting MySQL. SUCCESS!

 

9、登录mysql,修改密码(密码为步骤5生成的临时密码)

[root@VM_16_2_centos log]# mysql -u root -p eZ(u<__dV0#8

mysql> set password for root@localhost = password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

10、开放远程连接

mysql> use mysql;

mysql> update user set user.Host='%' where user.User='root';

mysql> flush privileges;

 

11、设置开机自动启动

1、将服务文件拷贝到init.d下,并重命名为mysql

[root@VM_16_2_centos log]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

2、赋予可执行权限

[root@VM_16_2_centos log]# chmod +x /etc/init.d/mysqld

3、添加服务

[root@VM_16_2_centos log]# chkconfig --add mysqld

4、显示服务列表

[root@VM_16_2_centos log]# chkconfig --list

 

12、利用navicator测试连接

 

成功撒花✿✿ヽ(°▽°)ノ✿

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿hww

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值