centos6卸载mysql服务器_CentOS6.5下卸载自带的MySQL数据库安装MySQL5.6
1)查看CentOS自帶的mysql
輸入 rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
2)將其自帶的mysql版本全部卸載(非常重要,如不卸載,后面會產生沖突)
rpm -e --nodeps (mysql版本號,就是上面檢查到的mysql-libs-5.1.71-1.el6.x86_64)
或者用這條命令卸載,yum -y remove mysql-libs*
3)檢查是否將自帶的mysql版本卸載了
rpm -qa | grep mysql
4)創建mysql的存放目錄(我保存在/usr/local/mysql目錄下,可以根據自己的喜好創建mysql的保存路徑)
mkdir /usr/local/mysql
進入到mysql目錄下
cd /usr/local/mysql
5)上傳mysql到?/usr/local/mysql/ 目錄下
上傳到 /usr/local/mysql/ 目錄后查看
ls
MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar
6)安裝
先解壓上傳的tar包
tar?-xvf?MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar
解壓后會得到以下rpm安裝文件:
MySQL-client-5.6.41-1.el6.x86_64.rpm
MySQL-devel-5.6.41-1.el6.x86_64.rpm
MySQL-embedded-5.6.41-1.el6.x86_64.rpm
MySQL-server-5.6.41-1.el6.x86_64.rpm
MySQL-shared-5.6.41-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.41-1.el6.x86_64.rpm
MySQL-test-5.6.41-1.el6.x86_64.rpm
安裝服務端(注意:服務端和客戶端都要安裝,否則會出錯)
rpm -ivh MySQL-server-5.6.41-1.el6.x86_64.rpm
出現報錯:
warning: MySQL-server-5.6.41-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
libnuma.so.1()(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.41-1.el6.x86_64
7)安裝所需要的依賴,分別執行以下命令
解決缺少perl的依賴:
yum install -y perl
解決缺少libaio.so.1(64bit)的依賴:
這里使用yum install –y libaio.so.1后發現并不能解決問題,原因yum安裝的并非x86_64版本,而是i686版本
rpm -qa | grep libaio
libaio-0.3.107-10.el6.i686
手動下載libaio-0.3.107-10.el6.x86_64.rpm,下載地址如下:
上傳后安裝
rpm?-ivh?libaio-0.3.107-10.el6.x86_64.rpm
解決缺少libnuma.so.1(64bit)依賴:
yum install -y numactl
再次安裝執行:
rpm -ivh MySQL-server-5.6.41-1.el6.x86_64.rpm
。。。省略。。。
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
安裝過程中提示默認為root用戶設置了隨機密碼,可以在 /root/.mysql_secret 文件中找到,并且移除了匿名用戶,可以運行 /usr/bin/mysql_secure_installation 命令來移除自帶的測試數據庫,還生成了默認配置文件 /usr/my.cnf
8)安裝客戶端
rpm -ivh MySQL-client-5.6.41-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.41-1.el6.x86_64.rpm
9)檢查是否安裝成功(注意MySQL字母的大小寫)
rpm -qa | grep MySQL
MySQL-server-5.6.41-1.el6.x86_64
MySQL-devel-5.6.41-1.el6.x86_64
MySQL-client-5.6.41-1.el6.x86_64
10)啟動mysql服務器
service mysql start
出現以下提示說明安裝成功!
Starting MySQL.Logging to '/var/lib/mysql/freeradius.err'.
. SUCCESS!
11)查看默認生成的隨機密碼(最后冒號后面的就是密碼)
cat /root/.mysql_secret
#?The random password set for the root user at Sun Sep 23 07:38:04 2018 (local time): psUGhQBPUZT_LPon
12)登陸mysql(輸入上一步找到的密碼)
mysql -u root -p
13)修改mysql登陸密碼
mysql> set password=password('密碼');
14)啟動mysql
service mysql start
15)將mysql加到系統服務中并設置開機啟動
加入到系統服務:chkconfig --add mysql
開機自動啟動:chkconfig mysql on
16)開啟mysql的遠程登錄
默認情況下mysql為安全起見,不支持遠程登錄mysql,所以需要設置開啟? 遠程登錄mysql的權限
登錄mysql后輸入如下命令:
mysql -u root -p
mysql> grant all privileges on *.* to 'root' @'%' identified by '密碼';
mysql> flush privileges;
17)開放Linux的對外訪問的端口3306
mysql默認沒有開啟對外訪問端口3306,需要手動開啟
/sbin/iptables
-I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save? ? ?# 將修改永久保存到防火墻中
18)初始設置mysql數據庫,設置root密碼,出于安全考慮,可以考慮刪除匿名用戶和測試數據庫以及禁用遠程根登錄,參見下面的示例配置。
運行?/usr/bin/mysql_secure_installation 命令
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] n
... skipping.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
19)修改配置文件位置并做相關設置
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
# 做如下配置
[client]
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
log_error = /var/log/mysql/error.log
# 錯誤日志路徑自己定義,前提是目錄必須存在
lower_case_table_names=1
# 注意 linux下mysql安裝完后是默認:表名區分大小寫,列名不區分大小寫; 0:區分大小寫,1:不區分大小寫
max_connections=1000
# 設置最大連接數,默認為 151,MySQL服務器允許的最大連接數16384
[mysql]
default-character-set = utf8
幾個重要目錄
數據庫目錄
/var/lib/mysql/
配置文件
/usr/share/mysql(mysql.server命令及配置文件)
相關命令
/usr/bin(mysqladmin mysqldump等命令)
啟動腳本
/etc/rc.d/init.d/(啟動腳本文件mysql的目錄)
總結
以上是生活随笔為你收集整理的centos6卸载mysql服务器_CentOS6.5下卸载自带的MySQL数据库安装MySQL5.6的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java mysql 是否插入 成功_您
- 下一篇: 哪些宠物有冰雹技能