mysql

00安装mysql

2020-04-04  本文已影响0人  我只是有点困_52b7

1、在mysql文件夹下建立data目录路径为

/usr/local/mysql/data

2、添加mysql用户组

groupadd mysql 
useradd -r -g mysql mysql

3、更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限

chown -R mysql:mysql /usr/local/mysql/
chmod -R 755 /usr/local/mysql/

4、在mysql的bin目录下编译安装并初始化

进入bin目录
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

记住初始化密码

2020-02-28T16:16:08.638314Z 1 [Note] A temporary password is generated for root@localhost: kSeF6serSe_H

5、编辑配置文件my.cnf

[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
#表名大小写不明感,敏感为
#lower_case_table_names=1
[mysqld_safe]
log-error=/usr/local/mysql/data/mariadb.log
pid-file=/usr/local/mysql/data/mariadb.pid
!includedir /etc/my.cnf.d

6、启动mysql

进人support-files目录
./mysql.server start

7、添加软连接,并重启mysql服务

ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart

8、进入mysql修改密码

set password for root@localhost = password('scarecrow');

9、开放远程连接

use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;

10、设置开机自动启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
上一篇下一篇

猜你喜欢

热点阅读