1.官网下载安装包,并传输到Linux
2.解压并移动
tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.27-linux-glibc2.12-x86_64 /usr/local/mysql
3.在mysql目录下创建mysql的相关配置文件
mkdir data/mysql
groupadd mysql useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
修改权限
chown -R mysql . chown -R mysql /data/mysql
配置
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql
注:运行成功会自动生成密码,切记要保存
将mysql.server从mysql/support-files/ 下复制到 /etc/init.d/mysql
4.新建文件 、etc/my.cnf
内容如下:
[mysqld] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 port=3306 datadir=/usr/local/mysql/data/mysql skip-grant-tables
5.执行
/etc/init.d/mysql start Starting MySQL.Logging to '/home/yoodb/mysql/data/mysql/ecs-1b35-0002.novalocal.err'. SUCCESS!
6.启动
service mysql start mysql -hlocalhost -uroot -p
修改密码
set password=password('1');
使可以远程连接
alter user 'root'@'%' identified with mysql_native_password by'1'; flush privileges;
7.检验是否成功
mysql--version
8.主机访问虚拟机Mysql时关闭防火墙命令
systemctl stop firewalld.service systemctl status firewalld
时关闭防火墙命令
systemctl stop firewalld.service systemctl status firewalld
apple_1900
发布了12 篇原创文章 · 获赞 0 · 访问量 123
私信
关注
标签:data,Linux,init,systemctl,usr,mysql,MySQL,local,远程
来源: https://blog.csdn.net/apple_1900/article/details/104010023