Mysql二进制安装

Mysql二进制安装,第1张

Mysql二进制安装 删除MariaDB
# rpm -qa|grep maria
mariadb-libs-5.5.65-1.el7.x86_64
# rpm -e mariadb-libs-5.5.65-1.el7.x86_64 --nodeps
安装依赖
yum install wget bison gcc gcc-c++ wget make cmake ncurses-devel libtool zilib-devel -y
解压
# tar -zxvf mysql-5.7.32-el7-x86_64.tar.gz -C /usr/local/  
cd /usr/local  
# ln -s mysql-5.7.32-el7-x86_64/ mysql
创建用户
groupadd mysql   
useradd -g mysql mysql  
echo "mysql"|passwd --stdin mysql
chown -R mysql:mysql /usr/local/mysql-5.7.32-el7-x86_64/
chown -R mysql:mysql /usr/local/mysql
创建目录
mkdir -p /data/data/  
mkdir -p /data/binlog/  
mkdir -p /data/log/  
chown -R mysql:mysql /data/
配置my.cnf
vim /etc/my.cnf
[mysqld]  
basedir=/usr/local/mysql/  
datadir=/data/data/  
log-bin=/data/binlog/mysql-bin  
log-bin-index=/data/binlog/binlog.index  
server-id=1  
port=3306  
socket=/data/mysql.sock  
user=mysql  
# Disabling symbolic-links is recommended to prevent assorted security risks  
symbolic-links=0  
explicit_defaults_for_timestamp=true  
 
[mysqld_safe]  
log-error=/data/log/mysqld.err  
pid-file=/data/log/mysqld.pid  
 
[mysql]  
socket=/data/mysql.sock

# chown -R mysql:mysql /etc/my.cnf  
配置环境变量
su - mysql  
vim .bash_profile  
MYSQL_HOME=/usr/local/mysql/  
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$MYSQL_HOME/bin  

export MYSQL_HOME  
export PATH  

source .bash_profile
初始化

最后会提示临时用户名密码

$ mysqld --defaults-file=/etc/my.cnf --initialize  
2021-03-25T09:47:02.521148Z 0 [Warning] InnoDB: New log files created, LSN=45790  
2021-03-25T09:47:02.559535Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.  
2021-03-25T09:47:02.630236Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0d14591f-8d4f-11eb-a507-000c291ae5c9.  
2021-03-25T09:47:02.631079Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.  
2021-03-25T09:47:03.864829Z 0 [Warning] CA certificate ca.pem is self signed.  
2021-03-25T09:47:04.178007Z 1 [Note] A temporary password is generated for root@localhost: k#rjoAROO3/j  

如下命令没有初始密码

$ mysqld --defaults-file=/etc/my.cnf initialize-insecure
启动

$ mysqld_safe --defaults-file=/etc/my.cnf &

修改密码
$ mysql -uroot -p
mysql> alter user root@localhost identified by 'root';
创建新库及用户
mysql> CREATE DATAbase hive charset utf8; 
mysql> USE hive; 
mysql> CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive';
mysql> GRANT ALL ON hive.* TO 'hive'@'localhost' IDENTIFIED BY 'hive'; 
mysql> GRANT ALL ON hive.* TO 'hive'@'%' IDENTIFIED BY 'hive'; 
mysql> FLUSH PRIVILEGES; 
mysql> quit;

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5704968.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存