当前位置:网站首页>【最全】linux服务器上安装Mysql
【最全】linux服务器上安装Mysql
2022-06-30 06:56:00 【菜鸟是大神】
将mysql下载到:/user/local/
cd /usr/local/wget https://dev.mysql.com/get/Downloads/mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz此处代表下载 8.0版本,可以在官网复制相应版本,修改对应位置,如:下载5.7版本:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz在该目录进行解压;
tar -xzf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 1、*.tar 用 tar -xvf 解压
2、*.gz 用 gzip -d或者gunzip 解压
3、.tar.gz和.tgz 用 tar -xzf 解压
4、*.bz2 用 bzip2 -d或者用bunzip2 解压
5、*.tar.bz2用tar -xjf 解压
6、*.Z 用 uncompress 解压
7、*.tar.Z 用tar -xZf 解压
8、*.rar 用 unrar e解压
9、*.zip 用 unzip 解压
10.*.tar.xz 用 tar -xJf 解压
修改解压后的文件夹名称,注意此处无.tar.gz后缀,否则是将压缩包文件名修改
mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql添加mysql文件夹所属的用户组和用户
groupadd mysqluseradd -r -g mysql mysql
创建数据库存放目录并授权,注意要先执行cd /在根目录下创建
cd /mkdir -p /data/mysql
配置my.cnf文件,根目录下执行:
vim /etc/my.cnf打开后将下面配置代码粘贴进去,按Enter键退出INSERT模式,输入:wq后按回车进行保存退出:(此处注意按i进入INSERT模式编辑)
[mysqld]bind-address=0.0.0.0port=3306user=mysqlbasedir=/usr/local/mysqldatadir=/data/mysqlsocket=/tmp/mysql.socklog-error=/data/mysql/mysql.errpid-file=/data/mysql/mysql.pid#character configcharacter_set_server=utf8mb4symbolic-links=0explicit_defaults_for_timestamp=true

初始化数据库,进入mysql的bin目录:
cd /usr/local/mysql/bin执行初始化并查看mysql账户密码:
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize在根目录下查看数据库初始密码:注意打印出来的日志最末尾 [email protected]:XXXXXXXXXXXXXX后的字符串为mysql管理员临时登录密码。
cd /cat /data/mysql/mysql.err
将mysql.server放置到/etc/init.d/mysql中
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql启动mysql,并查看是否启动成功
service mysql start下面进行修改数据库的初始密码
进入mysql的bin目录:
cd /usr/local/mysql/bin./mysql -u root -p
输入获取的数据库初始密码,执行下述3个命令,修改密码并刷新权限;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;FLUSH PRIVILEGES;
边栏推荐
- RT thread Kernel Implementation (II): critical area, object container
- Go installation and configuration (1)
- Develop common dependency Libraries
- Ffmplay is not generated during the compilation and installation of ffmpeg source code
- 【docsify基本使用】
- 1.6 - CPU composition
- 1.3 - Code System
- The most complete sentence in history
- 【Hot100】15. 三数之和
- It turns out that you are such an array. You have finally learned
猜你喜欢
![[daily question] 535 Encryption and decryption of tinyurl](/img/73/35674cd5df3d937af0762645041421.png)
[daily question] 535 Encryption and decryption of tinyurl

【每日一题】535. TinyURL 的加密与解密

tomorrow! "Mobile cloud Cup" competition air publicity will start!
![[datawhale team learning] task02: mathematical operation, string and text, list](/img/3e/c9c984d7576a2e410da7f81a8c0aa6.jpg)
[datawhale team learning] task02: mathematical operation, string and text, list

IDEA import导入的类明明存在,却飘红?

ROS system problem: rosdep init

Jingwei Hengrun won the 10ppm quality award of paccar group again

明天!“移动云杯”大赛空宣会开播!

2、 Layout system

Performance comparison of random network, scale-free network, small world network and NS small world matlab simulation
随机推荐
1.7 - CPU performance indicators
Keil - the "trace HW not present" appears during download debugging
Ftplib+ tqdm upload and download progress bar
ROS-URDF
Unity中实现溶解(Dissolve)特效及其原理解析
[transfer] analysis of memory structure, cache and DMA architecture
免实名域名是什么意思?
Problems and solutions of creating topic messages in ROS
KEIL - 下载调试出现“TRACE HW not present”
SOC project AHB_ SD_ Host controller design
leetcode:98. Validate binary search tree
[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts
RT thread Kernel Implementation (V): timer
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
【Hot100】15. Sum of three numbers
Jingwei Hengrun won the 10ppm quality award of paccar group again
CPU到底是怎么识别代码的?
【Hot100】15. 三数之和
Deploying web projects using idea
Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry