CentOS7编译安装MySQL5.6.45

CentOS7编译安装MySQL5.6.45

CentOS7编译安装MySQL5.6.45

基于CentOS7安装MySQL 5.6.45

提前准备:cmake-2.8.5.tar.gz mysql-5.6.45.tar.gz

yum -y install cmake gcc gcc-c++ bison ncurses ncurses-devel  perl autoconf cmake -y

安装过程:

mkdir -p  /cnet/data           创建数据库data目录

groupadd -r mysql

useradd -g mysql -s /sbin/nologin -M mysql

chown -R mysql:mysql    /cnet/data

rpm -qa | grep -i mysql

rpm -qa | grep -i mariadb

 

rpm -e mariadb-libs-5.5.56-2.el7.x86_64   –nodeps

(rpm -e mysql-libs  –nodeps)

 

tar zxvf cmake-2.8.5.tar.gz

cd cmake-2.8.5

./bootstrap

make && make install

 

tar zxvf mysql-5.6.36.tar.gz

cd mysql-5.6.36

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/cnet/data  -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

 

make -j 4  &&  make install

cd /usr/local/mysql/

chown -R mysql:mysql   /usr/local/mysql

 

cd /usr/local/mysql             初始化数据库

./scripts /mysql_install_db –user=mysql –datadir=/cnet/data

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf         ##复制Mysql配置文件

cp support-files/mysql.server /etc/init.d/mysqld                 ##复制启动文件

 

添加MySQL环境变量

vi /etc/profile

最后一行增加

PATH=$PATH:/usr/local/mysql/bin

export PATH

 

刷新环境变量

source /etc/profile

 

设置开机自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig –add mysqld

 

启动mysql:

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

 

—————————————————————————————————————————————-

登陆数据库:

mysql -uroot

mysqladmin -uroot password ‘sdaasd123129’  ##修改密码

或者:mysql> set password for root@localhost = password(‘123′);

mysql> grant all privileges on *.* to root@’%’ identified by ‘sddwd12312′;

mysql>revoke drop on volte.* from volte@’%’;    #撤销用户的drop权限

drop  user  volte@’%’;           #删除用户

mysql -uvolte -p’dddd@Volte’ -h192.168.181.117 -P13306          ##远程连接数据库

 

执行SQL 脚本:

mysql> use volte;

mysql> source  /tmp/cwang1.sql

mysql> show global variables like ‘port’;   #查看端口号

 

修改/etc/my.cnf  来修改数据库的端口:

[mysqld]

port=13306

 

本文版权归 飞翔沫沫情 作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接 如有问题, 可发送邮件咨询,转贴请注明出处:https://www.fxkjnj.com/266/

发表评论

登录后才能评论