欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

linux 用户状态安装mysql

程序员文章站 2022-06-27 19:43:21
下完安装包:wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz用户目录下解压:tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz创建文件夹mkdir mysqlln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql通过vi新增mysql配置文件my.cnf[clie...

下完安装包:
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

用户目录下解压:
tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

创建文件夹
mkdir mysql
ln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql

通过vi新增mysql配置文件my.cnf
[client]
port=3336
socket=/home/wpt/package/mysql/mysql.sock
[mysqld]
port=3336
basedir=/home/wpt/package/mysql
datadir=/home/wpt/package/mysql/data
pid-file=/home/wpt/package/mysql/mysql.pid
socket=/home/wpt/package/mysql/mysql.sock
log_error=/home/wpt/package/mysql/error.log
server-id=100

安装mysql
$ bin/mysqld --defaults-file=/home/wpt/package/mysql/my.cnf --initialize --user=WPT --basedir=/home/wpt/package/mysql --datadir=/home/wpt/package/mysql/data

启动mysql:
bin/mysqld_safe --defaults-file=/home/wpt/package/mysql/my.cnf --user=WPT &
获取密码
cat error.log | grep root@localhost

登陆mysql:
bin/mysql -u root -p

不存在/tmp/mysql.sock,我们在my.cnf配置的mysql.sock路径是/home/wlf/mysql/mysql.sock,所以当mysql去找这个文件时,我们让它换个地方去找:
ln -s /home/wpt/package/mysql/mysql.sock /tmp/mysql.sock

更改密码
set password for ‘root’@‘localhost’ = password(‘123456’);
flush privileges;

本文地址:https://blog.csdn.net/weixin_42699130/article/details/107346003

相关标签: linux