赞
踩
// 创建目录 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
[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
cd /usr/local/mysql8/bin
//初始化 注意成功后把最后面密码保存好,以后登录需要用到
./mysqld --initialize
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
//添加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
如果上面命令报如下错误:
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
如上即可完成登录,继续配置远程登录和修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
flush privileges;
use mysql;
update user set host='%' where user = 'root';
flush privileges;
exit
此时可以采用mysql连接工具连接;
欢迎访问木易成-开发者天地,不定时分享个人技术观点、股票交易经验、生活经历、NBA等精彩信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。