安装MYSQL5.7数据库后的操作
---------------------------------------
安装完后,初始化数据库
./bin/mysqld --basedir=/usr/local/mysql3308/ --datadir=/usr/local/mysql3308/data/ --initialize
初始化后,会生成一个临时密码,left
A temporary password is generated for root@localhost: Nd/rw0iBBTdb
然后启动 mysqld,可能会出现无法启动的情况 ,要查看datadir目录是不是属于mysql用户,并且有权限
记下这个临时密码,进下数据库,执行下面流程
mysql -uroot -p --host=127.0.0.1 --port=3308
报错:You must reset your password using ALTER USER statement before executing this statement.
执行下面语句,修改密码:
set password=password('root');
flush privileges;
配置文件
------------------------------------------------
kyle@xianglou:/usr/local/src$ cat /etc/mysql3308/my.cnf
[mysqld]
basedir=/usr/local/mysql3308
datadir=/usr/local/mysql3308/data
socket=/var/lib/mysql3308/mysql.sock
user=mysql
port=3308
bind-address = 127.0.0.1
symbolic-links=0
default-storage-engine=INNODB
character-set-filesystem=utf8mb4
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
skip-character-set-client-handshake
transaction_isolation = READ-COMMITTED
server-id=0
[client]
[mysqld_safe]
log-error=/var/log/mysqld3308.log
pid-file=/var/run/mysqld/mysqld3308.pid