You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.2 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

安装Mysql 5.7

yum install lrzsz -y
mkdir /usr/local -p
cd /usr/local
rz -be  选择 mysql-5.7.42-el7-x86_64.tar.gz
tar -zxf mysql-5.7.42-el7-x86_64.tar.gz
mv mysql-5.7.42-el7-x86_64 mysql
rm -rf mysql-5.7.42-el7-x86_64.tar.gz

vi /etc/profile
#添加如下内容
export PATH=/usr/local/mysql/bin:$PATH
#然后source生效
source /etc/profile

#添加用户并授权相关
useradd mysql
id mysql
mkdir /data/mysql -p
chown -R mysql:mysql /usr/local/mysql/*
chown -R mysql:mysql /data/*

其中:
/usr/local/mysql/是MySQL软件所在目录。
/data/mysql是将来存放MySQL数据的目录。

#初始化数据库
mysqld --initialize-insecure  --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql


#配置文件

vi /etc/my.cnf

[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
server_id=1
port=22066
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock

忽略大小写

lower_case_table_names=1

管理MySQL_etc/init.d

mkdir /etc/init.d -p
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

重定向文件

ln -s /usr/lib64/libncurses.so.6.2 /usr/lib64/libncurses.so.5
ln -s /usr/lib64/libtinfo.so.6.2 /usr/lib64/libtinfo.so.5

#启动、重启命令
service mysqld start
service mysqld restart

重置密码

/etc/init.d/mysqld stop

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql
update mysql.user set authentication_string=PASSWORD("DsideaL147258369") where user='root' and host='localhost';

flush privileges;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'DsideaL147258369' WITH GRANT OPTION; 

flush privileges;
exit

/etc/init.d/mysqld restart
mysql -uroot -pDsideaL147258369

现在用Navicat Prenium就可以远程访问到数据库了。

YLT项目中使用的用户名ycharge密码ycharge 需要创建
CREATE USER 'ycharge'@'%' IDENTIFIED BY 'ycharge';
GRANT all privileges ON yltcharge.* TO 'ycharge'@'%';
FLUSH PRIVILEGES;

创建使用账号

GRANT ALL PRIVILEGES ON *.* TO ycharge@"%" IDENTIFIED BY "ycharge";
flush privileges;