赞
踩
国产的麒麟系统也兼容此安装流程
本次安装系统信息uname -a
Linux sinovel 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
#下载安装包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
#解压文件并移动到/usr/local/mysql
tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql
#安装libaio开发包
sudo apt-get install libaio-dev -y
vi /etc/my.cnf
[mysqld]
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
[client]
port=3306
socket=/usr/local/mysql/data/mysql.sock
cd /usr/local/mysql
# 创建数据存放目录
mkdir data
#创建mysql用户组
groupadd mysql
useradd -g mysql mysql
#授予目录用户组和用户为mysql
chown -R mysql.mysql /usr/local/mysql/
./bin/mysqld --user=mysql --initialize
初始化过程中会答应默认生成的数据库密码。密码打印在日志A temporary password is generated for root@localhost:
后面。如本次生成的密码为:<GnflZFF<8Kv
2024-05-12T06:21:26.152752Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2024-05-12T06:21:26.152780Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2024-05-12T06:21:26.155869Z 0 [Warning] CA certificate ca.pem is self signed.
2024-05-12T06:21:26.399412Z 1 [Note] A temporary password is generated for root@localhost: <GnflZFF<8Kv
#复制mysql.server 脚本到/etc/init.d/mysql目录
sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
#更新配置启动服务
sudo update-rc.d mysql defaults 10
# 启动数据库
sudo systemctl start mysql
# 查看数据库状态 如看到 Active: active (running) 字样 表示启动成功
sudo systemctl status mysql
#切换到安装目录
sudo cd /usr/local/mysql
#连接mysql.并按提示输入上一步打印的默认密码
sudo bin/mysql -uroot -p
此命令需要在连接mysql之后执行
修改root密码为root
#修改默认密码为root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
#切换到mysql系统数据库
use mysql;
#修改为运行其他远程IP访问
update user set host='%' where user = 'root';
#刷新权限配置
flush privileges;
此步不是必须的,设置环境变量是访问在任意路径可以使用mysql工具命令行
sudo vim ~/.bashrc
#在文件中加入下面这2句 并保存。
PATH=$PATH:/usr/local/mysql/bin
export PATH
#重新加载环境变量配置
source ~/.bashrc
此时 可以在任意直接输入mysql -uroot -p进入mysql命令行终端。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。