安装方式选择: 二进制、源码、yum安装 (生产选择二进制安装)
参考链接:https://www.cnblogs.com/yyxianren/p/11319544.html
1.卸载默认安装的mariadb:
yum remove mariadb* -y
2.添加mysql用户:
useradd -s /sbin/nologin -M mysql
3.解压tar文件并移动到指定目录,并赋权:
tar zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.19-linux-glibc2.12-x86_64 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/
4.初始化mysql:(该操作之前要划分LVM)
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
5.创建系统服务,并修改参数:
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#修改上边俩行参数,添加指定的mysql目录和数据目录
6.修改配置文件:
vi /etc/my.cnf (参考:https://www.cnblogs.com/lijiaman/p/10743102.html)
[mysql]
default-character-set=utf8
[mysqld]
skip-name-resolve
port = 3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connections=1000
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=160M
添加环境变量:
vi .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
source .bash_profile
7.启动mysql:
/etc/init.d/mysqld start
8. 修改mysql密码及允许远程登录
mysql -uroot -p
mysql> set password=password('123456');
mysql> use mysql;
mysql> select host,user from user;
mysql> update user set host='%' where user='root';
mysql> flush privileges;
9.设置开机启动
10.安装要点:字符集、版本、引擎。
远程登录: mysql -h 192.168.200.9 -P 3608 -uroot -pm%N78v3n
字符集查看:show variables like '%char%';
引擎查看:show engines;
字符集查看:show variables like '%coll%';
set collation_database=utf8mb4_general_ci;
字符集更改:
use lsyth_qrtz;
ALTER DATABASE lsyth_sec CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
my.cnf配置修改:lower_case_table_names=1 (0改成1)方法:
在配置文件中加一行,lower_case_table_names=1
show variables like 'lower%';
然后重启服务即可,systemcctl restart mysqld
标签:set,安装,mysqld,usr,mysql,local,user From: https://www.cnblogs.com/huchao12/p/17557804.html