..1.下载linux的mysql安装包
https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-
x86_64.tar.gz
..2.上传到linux /usr/local/ 解压,重命名
cd /usr/local rz tar -zxvf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz mv mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz mysql
..3.创建数据文件夹
mkdir mysql/data/mysql
..4.添加用户组,添加用户
groupadd mysql useradd -r -g mysql mysql
ps:添加mysql这个用户组,并将mysql这个用户添加到mysql用户组中
..5.进入mysql目录,设置权限
cd mysql chown -R mysql:mysql ./ chown -R mysql:mysql data chown -R root:root ./
..6.安装数据库
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
..6.设置my.cnf文件,如果/usr/local/mysql/support-files/目录下有my-default.cnf
cp support-files/my-default.cnf /etc/my.cnf
如果没有则创建一个my.cnf文件
touch /etc/my.cnf vim /etc/my.cnf
.1{ [mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid }
chown mysql:mysql /var/run/mysqld chmod 750 /var/run/mysqld
ps:向my.cnf文件中添加上面.1大括号中的内容
..7.设置开机服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
..8.启动服务
service mysqld start
..9.进入到mysql目录,连接mysql
cd /usr/local/mysql/bin
mysql -uroot -p
..10.设置新的密码
GRANT USAGE ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT
OPTION;
ps:username为当前用户,password为新设置的密码
..11.设置允许远程访问
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH
GRANT OPTION;
ps:该命令为允许所有电脑访问
来源:https://www.cnblogs.com/zzb-yp/p/10644541.html