下载地址:http://mirrors.sohu.com/mysql/MySQL-5.6/
文件名:mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
cd /usr/local
tar -zxf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.39-linux-glibc2.12-x86_64/ mysql
- Centos7将默认数据库mysql,Centos7将默认数据库mariadb
rpm ‐qa|grep mysql
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
rpm -qa|grep mariadb
cd /etc
ls -l m*
rm /etc/my.cnf
groups mysql
groupadd mysql
useradd -g mysql mysql
mkdir /var/lib/mysql
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
ll m*
vi /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysqld]
skip-name-resolve
#设置3306端口
port = 3306
socket=/var/lib/mysql/mysql.sock
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
cd /usr/local/mysql
chown -R mysql:mysql ./
--备注:修改当前目录拥有着为mysql用户
yum install -y net-tools.x86_64 autoconf iptables-services
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --explicit_defaults_for_timestamp
chown 777 /etc/my.cnf
chown 777 /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
说明:表明mysqld服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制mysql的启动和停止
service mysqld start/stop
vi ~/.bash_profile
source ~/.bash_profile
export
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
export PATH
- 以root账户登录mysql,默认是没有密码的
mysql -uroot -p
- 修改root账号密码root
use mysql;
update user set password=password(‘root‘) where user=‘root‘ and host=‘localhost‘;
- 授权给其他电脑
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH
GRANT OPTION;
- 刷新权限
flush privileges;
暂无。
rpm -qa|grep -i mysql
-删除命令:rpm -e –nodeps
包名
[root@centos1 ~]# find / -name mysql
rm -rf /run/lock/subsys/mysql
···
rm -rf /etc/my.cnf
https://www.centoschina.cn/server/sql/mysql/9276.html
原文:https://www.cnblogs.com/kunlingou/p/11147590.html