1.准备好安装包 上传更目录
本文基于mysql 5.7.22
2.
编辑my.cnf配置文件,放在当前mysql安装目录下,配置文件路径/home/2iuser/mysql/my.cnf 。
[client]
port=3306
socket=/home/[client]
port=3306
socket=/home/whr/mysql/mysql.sock
[mysqld]
port=3306
basedir=/home/whr/mysql
datadir=/home/whr/mysql/data
pid-file=/home/whr/mysql/mysql.pid
socket=/home/whr/mysql/mysql.sock
log_error=/home/whr/mysql/error.log
server-id=100/mysql/mysql.sock
3.进入mysql目录,开始安装mysql。
bin/mysqld --defaults-file=/home/whr/mysql/my.cnf --initialize --user=root --basedir=/home/whr/mysql --datadir=/home/whr/mysql/data
4.启动
bin/mysqld_safe --defaults-file=/home/whr/mysql/my.cnf --user=root &
5.获取密码
cat error.log | grep root@localhost
6.登陆
bin/mysql -u root -p -S /home/whr/mysql/mysql.sock
7.修改密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
flush privileges;
8.设置远程访问
grant all PRIVILEGES on *.* to root@'%' identified by 'root的密码';
flush privileges;
ps:
1.启动如果报错
121206 11:14:09 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
121206 11:14:09 [ERROR] Do you already have another mysqld server running on port: 3306 ?
解决:
ps aux |grep mysq*
查看进程,然后全部kill掉,重试。
2.多注意情动方式,必须制定sock目录