当前位置:   article > 正文

linux安装mysql8详细教程

linux安装mysql8

linux安装mysql8

// 创建目录
cd usr/local
mkdir mysql8

// 下载mysql8
cd src
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.18-el7-x86_64.tar.gz

// 解压
tar zxvf mysql-8.0.18-el7-x86_64.tar.gz

//移动到mysql8下
mv /usr/local/src/mysql-8.0.18-el7-x86_64/* /usr/local/mysql8
cd /usr/local/mysql8
//如果没有data可以创建一个
mkdir data

// 创建组和用户并赋权限
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /usr/local/mysql8

//更改配置 添加如下内容
vi /etc/my.cnf
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
[mysqld]
user=root
datadir=/usr/local/mysql8/data
basedir=/usr/local/mysql8
port=3306
max_connections=200
max_connect_errors=10
character-set-server=utf8
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
lower_case_table_names=1
group_concat_max_len=102400
[mysql]
default-character-set=utf8
[client]
port=3306
default-character-set=utf8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
cd /usr/local/mysql8/bin
//初始化  注意成功后把最后面密码保存好,以后登录需要用到
./mysqld --initialize
  • 1
  • 2
  • 3

A temporary password is generated for root@localhost: 78weJv54>.k
如果上面报错:./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory;执行下面命令

yum -y install libaio
  • 1
//添加mysqld服务到系统
cd /usr/local/mysql8
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql

//启动mysql
service mysql start
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

如果上面命令报如下错误:
Starting MySQL.Logging to ‘/var/log/mariadb/mariadb.log’.
ERROR! The server quit without updating PID file (/usr/local/mysql8/data/ldclouda25461.pid).
创建文件mariadb.log

cd /var/log
mkdir mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb/

//在启动
service mysql start
ln -s /usr/local/mysql8/bin/mysql /usr/bin

//登录mysql,密码输入上面保存密码
mysql -uroot -p
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

如上即可完成登录,继续配置远程登录和修改密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
flush privileges;

use mysql;
update user set host='%' where user = 'root';
flush privileges;
exit
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

此时可以采用mysql连接工具连接;

欢迎访问木易成-开发者天地,不定时分享个人技术观点、股票交易经验、生活经历、NBA等精彩信息。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/923418
推荐阅读
相关标签
  

闽ICP备14008679号