虚拟机centos安装启动mysql
https://blog.csdn.net/dc282614966/article/details/81098074一、下载二、安装1.将下载好的安装到解压到/usr/local目录下tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64 -C /home/soft/mysql7-21/mysql/2.进入/usr/local目录cd /...
https://blog.csdn.net/dc282614966/article/details/81098074
一、下载
二、安装
1.将下载好的安装到解压到/usr/local目录下
tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64 -C /home/soft/mysql7-21/mysql/
2.进入/usr/local目录
cd /home/soft/mysql7-21/mysql/
3.为mysql安装目录创建软链接
ln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql
4.为centos添加mysql用户组和mysql用户(-s /bin/false参数指定mysql用户仅拥有所有权,而没有登录权限)
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
如果已经有了mysql用户进行
userdel -rf mysql
操作
5.进入安装mysql软件的目录,命令如下
cd /home/soft/mysql7-21/mysql/
6.修改当前目录拥有者为新建的mysql用户,命令如下:
chown -R mysql:mysql ./
7.安装mysql,命令如下:
./bin/mysqld --user=mysql --basedir=/home/soft/mysql7-21/mysql --datadir=/home/soft/mysql7-21/mysql/data --initialize
可能需要进入
vim /home/soft/mysql7-21/mysql/support-files/ mysql.server
修改 为如下
basedir=/home/soft/mysql7-21/mysql
bindir=/home/soft/mysql7-21/mysql/bin
必须为自己安装的目录
如果出现如下图所示则为安装成功,红线部分为生成的默认密码:
8.开启mysql服务,命令如下:
./support-files/mysql.server start
如果出现如下错误,则说明mysql配置文件/etc/my.cnf中的路径不对,修改内容如下,datadir和socket都修改成mysql的安装目录下,增加[client]板块,用于命令行连接mysql数据库。
[mysqld]
port=3306
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
user=mysql
max_connections=151
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# 设置忽略大小写
lower_case_table_names = 1
# 指定编码
character-set-server=utf8
collation-server=utf8_general_ci
# 开启ip绑定
bind-address = 0.0.0.0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#指定客户端连接mysql时的socket通信文件路径
[client]
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8
9.如果出现如下
Starting MySQL...The server quit without updating PID file [FAILED]oft/mysql7-21/mysql/data/izbp1a3x6amr0c6lksqmymz.pid).
很有可能是因为本地mysql3306端口起着,将
[mysqld]
port=3306
修改为
[mysqld]
port=3307
更换一个端口
再次启动
./support-files/mysql.server start
更多推荐
所有评论(0)