mysql
· 阅读需 2 分钟
mysql的编译和配置
yum install libaio
ln -s /usr/lib64/libncurses.so.5.6 /lib64/libtinfo.so.5
#创建用户
groupadd mysql
useradd mysql -g mysql -s /bin/false
cd /usr/local
#wget
tar zxvf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
rm -f mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
#mv mysql-5.7.33-linux-glibc2.12-x86_64 mysql
ln -s /usr/local/mysql-5.7.33-linux-glibc2.12-x86_64 ./mysql
mkdir mysql/log
mkdir mysql/data
chown mysql:mysql mysql/data mysql/log
chmod 750 mysql/data mysql/log
cd mysql
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
bin/mysqld_safe --user=mysql
#export PATH=$PATH:/usr/local/mysql/bin
其中在初始化时应该会有一条类似这样的消息
[Warning] A temporary password is generated for root@localhost: abcdefg
其中的abcdefg
部分就是临时的root密码,把它记下,下次登录使用,
在登陆前,先在log目录下建立一个my.cnf文件(记得改权限),内容如下:
[mysqld]
explicit_defaults_for_timestamp
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/log/msg.log
user=mysql
然后启动mysql,再登陆
#下面这条在服务器上开个终端单独执行,
#它会一直运行,不会退出来
bin/mysqld --defaults-file=/usr/local/mysql/log/my.cnf
#下面这个可以在其他地方运行,连接mysql
bin/mysql -u root -p
登录,输入mysql的root密码,
然后重置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
为wordpresss创建数据库
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON databasename.* TO "wordpress"@"localhost"
IDENTIFIED BY "password";
FLUSH PRIVILEGES;