1. 程式人生 > >centOS 6.5 安裝 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

centOS 6.5 安裝 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

下載地址: https://dev.mysql.com/downloads/mysql/5.7.html#downloads

#解除安裝系統自帶的Mariadb

[[email protected] local]# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64

[[email protected] local]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

#刪除etc目錄下的my.cnf檔案
[[email protected] local]# rm /etc/my.cnf
rm: 無法刪除"/etc/my.cnf": 沒有那個檔案或目錄

#檢查mysql是否存在
[

[email protected] local]# rpm -qa | grep mysql
[[email protected] local]# 

#檢查mysql組和使用者是否存在,如無建立
[[email protected] local]# cat /etc/group | grep mysql
[[email protected] local]# cat /etc/passwd | grep mysql

#建立mysql使用者組
[[email protected] local]# groupadd mysql
#建立一個使用者名稱為mysql的使用者並加入mysql使用者組
[
[email protected]
local]# useradd -g mysql mysql

#制定password 為**************
[[email protected] local]# passwd mysql
更改使用者 mysql 的密碼 。
新的 密碼:
重新輸入新的 密碼:
passwd:所有的身份驗證令牌已經成功更新。

解壓到指定資料夾下
tar -vxzf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.21-linux-glibc2.12-x86_64/ /usr/local/mysql/

#更改所屬的組和使用者
[[email protected] local]# chown -R mysql mysql/
[[email protected] local]# chgrp -R mysql mysql/
#在mysql資料夾下建立  資料庫資料儲存目錄  data
[[email protected] local]# cd mysql/
[[email protected] mysql]# mkdir data
[[email protected] mysql]# chown -R mysql:mysql data

#在etc下新建配置檔案my.cnf,並在該檔案內新增以下配置
[mysql]
# 設定mysql客戶端預設字符集
default-character-set=utf8 
[mysqld]
skip-name-resolve
#設定3306埠
port = 3306 
# 設定mysql的安裝目錄
basedir=/usr/local/mysql
# 設定mysql資料庫的資料的存放目錄
datadir=/usr/local/mysql/data
# 允許最大連線數
max_connections=200

# 服務端使用的字符集預設為8位元編碼的latin1字符集

character-set-server=utf8mb4 # 支援表情符號
# 建立新表時將使用的預設儲存引擎
default-storage-engine=INNODB 
lower_case_table_names=1
max_allowed_packet=16M

#安裝和初始化
[[email protected] mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

2018-03-07 20:15:37 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018-03-07 20:15:41 [WARNING] The bootstrap log isn't empty:
2018-03-07 20:15:41 [WARNING] 2018-03-07T12:15:38.240438Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2018-03-07T12:15:38.281730Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-03-07T12:15:38.281756Z 0 [Warning] Changed limits: table_open_cache: 407 (requested 2000)

[[email protected] mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
#將指令碼檔案設定成可執行檔案
[[email protected] mysql]# chown 777 /etc/my.cnf
[[email protected] mysql]# chmod a+x /etc/init.d/mysqld

[[email protected] mysql]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS! 
[[email protected] mysql]# killall mysqld
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[[email protected] mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
#設定開機啟動
[[email protected] mysql]# chkconfig --level 35 mysqld on
[[email protected] mysql]# chkconfig --list mysqld
注意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置資料可能被原生 systemd 配置覆蓋。 
      如果您想列出 systemd 服務,請執行 'systemctl list-unit-files'。
      欲檢視對特定 target 啟用的服務請執行
      'systemctl list-dependencies [target]'。
 

mysqld             0:關    1:關    2:開    3:開    4:開    5:開    6:關


[[email protected] mysql]# chmod +x /etc/rc.d/init.d/mysqld
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig --list mysqld
[[email protected] mysql]# service mysqld status
 SUCCESS! MySQL running (6272)
#編輯  vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
[[email protected] mysql]# source /etc/profile
#獲得初始密碼
[[email protected] bin]# cat /root/.mysql_secret 
# Password set for user '[email protected]' at 2018-03-07 20:15:37 
hgfs1Z1uMw2=

#修改密碼
[[email protected] bin]# mysql -uroot -p

[[email protected] init.d]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
#先關閉mysql
[[email protected] init.d]# ./mysqld stop
Shutting down MySQL.. SUCCESS! 

#使用安全模式登陸,跳過密碼驗證


[[email protected] init.d]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking&
[1] 7059
[[email protected] init.d]# 2018-03-07T12:50:12.826995Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2018-03-07T12:50:12.861526Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[[email protected] init.d]# mysql -uroot  mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password = password('**************') ;
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[[email protected] init.d]# ls
functions  mysqld  netconsole  network  README
[[email protected] init.d]# ./mysqld 
Usage: mysqld  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]
[[email protected] init.d]# ./mysqld restart
Shutting down MySQL..2018-03-07T12:54:40.379190Z mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
 SUCCESS! 
Starting MySQL. SUCCESS! 
[1]+  完成                  mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[[email protected] init.d]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password ('**************');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit;
Bye
[[email protected] init.d]# ps -ef|grep mysql
root       7407      1  0 20:54 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
mysql      7608   7407  0 20:54 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid --port=3306
root       7660   5149  0 20:57 pts/0    00:00:00 grep --color=auto mysql
[[email protected] init.d]# ls
functions  mysqld  netconsole  network  README
[[email protected] init.d]# ./mysqld stop
Shutting down MySQL.. SUCCESS! 
[[email protected] init.d]# ps -ef|grep mysql
root       7696   5149  0 20:57 pts/0    00:00:00 grep --color=auto mysql
[[email protected] init.d]# reboot
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Connection closing...Socket close.
 

Connection closed by foreign host.

#新增遠端訪問許可權
[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)
#這裡 @‘%’ 表示在任何主機都可以登入
mysql> create user 'xxx'@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)
#重啟mysql
[[email protected] init.d]# ./mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
#為了在任何目錄下可以登入mysql
[[email protected] init.d]# ln -s /usr/local/mysql/bin/mysql   /usr/bin/mysql

相關推薦

centOS 6.5 安裝 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

下載地址: https://dev.mysql.com/downloads/mysql/5.7.html#downloads #解除安裝系統自帶的Mariadb [[email protected] local]# rpm -qa|grep mariadb

linux系統centOS 7安裝 mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

#解除安裝系統自帶的Mariadb [[email protected] local]# rpm -qa|grep mariadb mariadb-libs-5.5.52-1.el7.x86_64 [[email protected] local]# rpm -e --nodep

mysql安裝-CentOS6下解壓安裝mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

cannot x86 sed 一次 article www. 連接 初始 fresh 刪除已經安裝版本 yum list installed mysql [root@localhost ~]# yum list installed mysql Loaded plugi

CentOS7下安裝mysql安裝版(mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz)

1.從mysql官網下載二進位制安裝包(https://dev.mysql.com/downloads/mysql/) 2.檢查是否已經安裝了mysql或者是MariaDB,如果已經安裝,則先把安裝的解除安裝 [[email protected] software]#

CentOsmysql-5.6.39-linux-glibc2.12-x86_64.tar.gz壓縮包的安裝

sorted sql mbo blog 密碼 回車 安裝mysql 下載安裝 window 之前寫過一篇mysql在windows下的安裝(猛擊這兒),linux下用的比較少,最近切換到linux服務器了,發行mysql安裝和windows下有所不同,只記錄壓縮包方式安裝,

ubuntu 16.04下安裝 mysql-connector-c-6.1.11-linux-glibc2.12-x86_64.tar.gz

最近在玩MySQL,就想著用c語言去連結資料庫,看了網上的c語言連結資料的例子,怎麼也執行不了; 網上說要安裝一個庫,如下: 安裝:sudo apt-get install libmysqlclient-dev 不知道是不是我電腦的原因,這種裝過以後報了錯誤,好像是:mysql-com

CentOS 6.9安裝MySQL 5.6 (使用yum安裝

移除CentOS預設的mysql-libs [[email protected]test01 srv]# whereis mysql mysql: /usr/lib64/mysql /usr/share/mysql [[email protected]t

centos安裝mysql-5.7.24-linux-glibc2.12-x86_64

目錄 安裝 下載mysql 下載完成後,將壓縮包放到 /usr/local  目錄下 本文下載的是  mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 安裝 解壓 # 切換目錄 [[email

虛擬機器下CentOS 6.x安裝MySQL 5.6.x

linux系統:CentOS6.9-i386 mysql版本:MySQL-5.6.22-1.el6.i686.rpm-bundle.tar 保持聯網 PS:mysql作者從甲骨文公司離職,甲骨文有將mysql閉源的打算,所以CentOS 7系列預設不再支援

Centos6.4 + mysql-5.6.38-linux-glibc2.12-x86_64.tar 實現mysql主從復制

ide mysql-bin log_file color log-bin mysq fig isam 直接 mysql安裝方法:http://www.cnblogs.com/lin3615/p/4376224.html 用到的是兩臺服務器 主:192.168.1.1

Linux安裝mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz

花了我一天時間,我得記錄下 總體來說熟悉了之後就好安裝了,開頭不懂要怎麼配置走了不少彎路 官網下載這個,其他的可能會有問題,我開頭下載了第三個配置不成功 1.解壓mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz到/u

mysql-8.0.16-linux-glibc2.12-x86_64

檢查 ali 包括 next use linux man serve user MySQL5數據庫安裝部署 準備卸載之前安裝過的版本確保之前安裝過的版本完全卸載,包括老版本使用的數據文件。檢查“/etc/my.cnf”,“/etc/

centos 6.5 安裝mysql 5.7.21 community

connect edi 主機 查看 restart 特殊 generated src req Step1: 檢測系統是否自帶安裝mysql # yum list installed | grep mysql Step2: 刪除系統自帶的mysql及其依賴命令: # yum

CentOS 7.5 安裝 MySQL 5.6 並配置環境變數

概述: 通過原始碼安裝高版本的5.6.14。   正文: 一:解除安裝舊版本 使用下面的命令檢查是否安裝有MySQL Server rpm -qa | grep mysql 有的話通過下面的命令來解除安裝掉 目前我們查詢到的是這樣的: [[email

centos 7.3 安裝 mysql-5.7.22-linux-glibc2.5-x86_64

1、下載: [[email protected] ~]#  wget  https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.5-x86_64.tar.gz 

CentOS 6.5 安裝 MySQL cluster 7.4.8 的安裝配置

一、準備 軟體環境 :VMware 10、CentOS 6.5、MySQL cluster 7.4.8  1、兩臺虛擬機器IP分別為192.168.80.140、192.168.80.142 2、節點規劃: 節點

centos 6.6 yum安裝mysql 5.7.16

先到 yum 安裝庫 http://repo.mysql.com/  查詢需要的mysql yum 包 這裡用mysql57-community-release-el6-8.noarch   安裝5.

centos 6.5安裝MySQL 5.6.35

linux mysql下載軟件[[email protected]/* */ src]# wget -q http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz解壓[[email 

CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本)

相關連結: 在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版 在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本) 在 CentOS 1804 中 修改 MySQL 密碼策略 在 CentOS 中 開啟 MySQL 的

Centos 6.5安裝mysql 5.5

#列出安裝的mysql  rpm -qa | grep mysql #centos6.5 basic server 版本 預設安裝了mysql5.1,所以先解除安裝mysql5 yum -y remove mysql-libs-5.1*   1.安裝