建网站框架LAMP之:MYSQL的安装
作者:互联网
-
下载mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz:
https://dev.mysql.com/downloads/mysql/
-
拷贝文件mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz至 linux 系统目录: /usr/local/src
-
tar -xf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz, 得到文件:mysql-8.0.17-linux-glibc2.12-x86_64.tar
-
tar -zxvf mysql-8.0.17-linux-glibc2.12-x86_64.tar
-
mv mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/
-
mv /usr/local/ mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/zwk_mysql
-
mkdir /usr/local/zwk_data
-
groupadd zwkmysql
-
useradd -g zwkmysql zwkmysql
-
chown -R zwkmysql.zwkmysql /usr/local/zwk_mysql /usr/local/zwk_data
-
初始化数据库
11.1 创建mysql_install_db安装文件 (好像没有用)
mkdir mysql_install_db
chmod 777 ./mysql_install_db
11.2 初始化
/usr/local/zwk_mysql/bin/mysqld --initialize --user=zwkmysql --basedir=/usr/local/zwk_mysql --datadir=/usr/local/zwk_data
//初始化数据库
/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 5826
[Server] A temporary password is generated for root@localhost: twi=Tlsi<0O!
/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed
记录好自己的临时密码:
twi=Tlsi<0O!
这里可能遇到了问题:没有libnuma.so.1
zsh: command not found: mysqld
./bin/mysqld --initialize
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解决办法:
yum install libaio
安装文件
- mysql配置
cp /usr/local/zwk_mysql/support-files/mysql.server /etc/init.d/
修改my.cnf文件
vim /etc/my.cnf
[mysqld]
basedir = /usr/local/zwk_mysql
datadir = /usr/local/zwk_data
socket = /usr/local/ zwk_mysql/zwkmysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/ zwk_mysql/ zwkmysql.sock
default-character-set=utf8
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/usr/local/zwk_data/zwkmysql.pid
esc保存
:wq 退出
-
修改日志文件的权限(这一定要改,不然无法启动)
chown -R zwkmysql.zwkmysql /var/log/mariadb
chown -R zwkmysql.zwkmysql /var/log/mariadb/mariadb.log -
建立MySQL服务
cp -a /usr/local/zwk_mysql/support-files/mysql.server /etc/init.d/zwkmysqld
chmod +x /etc/init.d/ zwkmysqld
添加到系统服务
chkconfig --add zwkmysqld
检查服务是否生效
chkconfig --list mysqld
- 配置全局环境变量
编辑 / etc/profile 文件
vi /etc/profile
在 profile 文件底部添加如下两行配置,保存后退出
export PATH=$PATH:/usr/local/zwk_mysql/bin:/usr/local/zwk_mysql/lib
export PATH
设置环境变量立即生效
source /etc/profile
-
修改:vim /etc/init.d/zwkmysqld
-
启动MySQL服务
service mysql start -
登录MySQL
mysql -uroot -p密码
修改密码:
alter user ‘root’@’locahost’ identified by ‘P123456’; #对应的换成你自己的密码即可了。
标签:zwk,建网站,MYSQL,LAMP,mysqld,usr,mysql,zwkmysql,local 来源: https://blog.csdn.net/ailloy888/article/details/99705124