1.下载(/usr/local目录)
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
2.解压
tar -zvxf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
3.创建目录
mv mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz mysql
mkdir /usr/local/mysql/data
4.创建用户和组
groupadd mysql
useradd -r -s /sbin/nologin -g mysql -d /usr/local/mysql mysql
5.更改权限
chown -R mysql:mysql /usr/local/mysql
6.安装
./mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
记住临时密码
如出现
则
ununtu系统:apt-get install libaio1 libaio-dev
centos系统:yum install libaio yum -y install numactl
7.添加配置文件
vim /etc/my.cnf
[mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock user=mysql port=3306 character_set_server=utf8 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/usr/local/mysql/data/error.log pid-file=/usr/local/mysql/data/mysqld.pid tmpdir=/tmp
8.设置为服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改配置
vim /etc/init.d/mysql.d
basedir=/usr/local/mysql datadir=/usr/local/mysql/data mysqld_pid_file_path=/usr/local/mysql/data/mysqld_pid
启动mysql-service
cd /etc/init.d
./mysqld start
ubuntu
centos
成功后即可作为服务启动
service mysqld start/status/stop
9.客户端连接
./usr/local/mysql/bin/mysql -uroot -p
输入临时密码
centos系统可能会出现
执行yum -y install libncurses*
10.设置密码
set password for 'root'@localhost=password('root123');
flush privileges
11.开启root用户远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码';
flush privileges;
12.mysql程序目录配置到环境变量
vim /etc/profile
在底部新增
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
即可在任意路径登录mysql
参考博客:
https://blog.csdn.net/zhengfeng2100/article/details/53482617
https://www.cnblogs.com/ZXF6/p/11552808.html
https://www.cnblogs.com/ZXF6/p/11552808.html
https://help.directadmin.com/item.php?id=368
https://blog.csdn.net/liukai6/article/details/78323364
https://blog.csdn.net/weixin_43849519/article/details/104832300