然后写入以下内容
[client]
socket = /tmp/mysql.sock
[mysqld]
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
⑤开启服务
详细参考https://dev.mysql.com/doc/refman/8.0/en/postinstallation.html。
配置mysqld服务。
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
update-rc.d mysqld defaults
service mysqld start
添加PATH。
echo -e '# MySQL PATH\nexport PATH=/usr/local/mysql/bin:$PATH\n' >> /etc/profile
source /etc/profile
连接登录MySQL并修改root账户密码(需要使用第④步生成的密码)。
mysql -uroot -p'!YAH0uS%AS>q'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '1024';
因为本次安装只是个人使用(非生产环境),所以可以额外的将账户密码信息写入配置文件,以后连接就不用再输入了(懒人专用)。然后进入MySQL修改开启root账户可远程连接。
把这几行添加到client选项组下面
vim /etc/my.cnf
user = root
password = 1024
port = 3306
然后试着启动一下mysql,其下的 UPDATE 语句是为了使远程用户也能连接上mysql。
root@zoo:/home/zoo/mysql-8.0.16# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.16 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owner