yum install wget
yum install perl perl-devel
cd /usr/local/src
wget
tar zxvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql
useradd -s /sbin/nologin mysql
建立存放資料的目錄:
mkdir -p /data/mysql
chown -r mysql:mysql /data/mysql/
執行:cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
配置檔案:
cp my.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld ,在配置裡找到 basedir datadir 進行設定
basedir=/usr/local/mysql
datadir=/data/mysql
chkconfig --add mysqld
chkconfig mysqld on
管理mysqld服務:
systemctl status mysqld
systemctl stop mysqld
systemctl start mysqld
在/etc/profile 新增資訊:
vim /etc/profile
export path=$path:'/usr/local/mysql/bin'
source /etc/profile
設定mysql密碼:
mysqladmin -uroot password '123456'
清除歷史記錄:
history -c
如果無法修改密碼,可使用以下方式進行修改
>systemctl stop mysqld
>mysqld_safe --skip-grant-tables &
輸入 mysql -uroot -p 回車進入
>use mysql;
> update user set password=password("www.code306.cn")where user="root"; #更改密碼為 newpass
> flush privileges; #更新許可權 > quit #退出
>service mysqld restart
>mysql -uroot -pnewpass #新密碼進入
修改mysql密碼:
mysql -u root
mysql> use mysql;
mysql>
update
user
set
password
=
password
(
'newpass'
)
where
user
=
'root'
;
mysql> flush
privileges
;
mysql允許遠端登入:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
mysql忘記密碼:
2.在[mysqld]下新增skip-grant-tables,然後儲存並退出
3.重啟mysql服務
4.重啟以後,執行mysql命令進入mysql命令列
Centos7離線安裝mysql5
2.將部署包存放到 opt 資料夾下 3.解壓並安裝 cd opt mkdir mysql tar xvf opt mysql 5.7.30 1.el7.x86 64.rpm bundle.tar c opt mysql cd opt mysql rpm uvh rpm nodeps force1....
Centos7使用yum安裝Mysql5 7
centos7的yum源中預設是沒有mysql,因為現在已經用mariadb代替mysql了。安裝mysql rpm包 rpm ivh mysql57 community release el7 11.noarch.rpm 安裝mysql yum install mysql community se...
Centos 7 使用yum安裝mysql 5 7
wget 2 安裝mysql yum y install mysql57 community release el7 10.noarch.rpm yum y install mysql community server 3 啟動mysql systemctl start mysqld.service...