Last login: Mon Aug 11 18:27:56 2014 from 192.168.1.101
[root@localhost ~]# rpm -qa|grep mysql #查看一下目前系统中自带的mysql组件
mysql-5.1.73-3.el6_5.i686
mysql-libs-5.1.73-3.el6_5.i686
mysql-devel-5.1.73-3.el6_5.i686
[root@localhost ~]# rpm -e --nodeps mysql #卸载自带的mysql组件
[root@localhost ~]# rpm -e --nodeps mysql-devel-5.1.73-3.el6_5.i686
[root@localhost ~]# rpm -qa|grep mysql
mysql-libs-5.1.73-3.el6_5.i686
[root@localhost ~]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.i686
[root@localhost ~]# rpm -qa|grep mysql
[root@localhost ~]# rpm -qa|grep MySQL
[root@localhost ~]# yum list|grep mysql #查看使用yum要安装的版本信息
apr-util-mysql.i686 1.3.9-3.el6_0.1 base
bacula-director-mysql.i686 5.0.0-12.el6 base
bacula-storage-mysql.i686 5.0.0-12.el6 base
dovecot-mysql.i686 1:2.0.9-7.el6_5.1 updates
freeradius-mysql.i686 2.1.12-4.el6_3 base
libdbi-dbd-mysql.i686 0.8.3-5.1.el6 base
mod_auth_mysql.i686 1:3.0.0-11.el6_0.1 base
mysql.i686 5.1.73-3.el6_5 updates
mysql-bench.i686 5.1.73-3.el6_5 updates
mysql-connector-java.noarch 1:5.1.17-6.el6 base
mysql-connector-odbc.i686 5.1.5r1144-7.el6 base
mysql-devel.i686 5.1.73-3.el6_5 updates
mysql-embedded.i686 5.1.73-3.el6_5 updates
mysql-embedded-devel.i686 5.1.73-3.el6_5 updates
mysql-libs.i686 5.1.73-3.el6_5 updates
mysql-server.i686 5.1.73-3.el6_5 updates
mysql-test.i686 5.1.73-3.el6_5 updates
php-mysql.i686 5.3.3-27.el6_5.2 updates
qt-mysql.i686 1:4.6.2-28.el6_5 updates
rsyslog-mysql.i686 5.8.10-8.el6 base
[root@localhost ~]# yum -y install mysql-server mysql mysql-devel #安装mysql服务端 客户端
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.aliyun.com
* updates: mirrors.yun-idc.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql-libs = 5.1.73-3.el6_5 for package: mysql-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16) for package: mysql-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient_r.so.16 for package: mysql-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: mysql-5.1.73-3.el6_5.i686
--> Processing Dependency: libmysqlclient.so.16 for package: mysql-5.1.73-3.el6_5.i686
---> Package mysql-devel.i686 0:5.1.73-3.el6_5 will be installed
---> Package mysql-server.i686 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-3.el6_5.i686
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-3.el6_5.i686
--> Running transaction check
---> Package mysql-libs.i686 0:5.1.73-3.el6_5 will be installed
---> Package perl-DBD-MySQL.i686 0:4.013-3.el6 will be installed
---> Package perl-DBI.i686 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql i686 5.1.73-3.el6_5 updates 903 k
mysql-devel i686 5.1.73-3.el6_5 updates 129 k
mysql-server i686 5.1.73-3.el6_5 updates 8.8 M
Installing for dependencies:
mysql-libs i686 5.1.73-3.el6_5 updates 1.2 M
perl-DBD-MySQL i686 4.013-3.el6 base 134 k
perl-DBI i686 1.609-4.el6 base 705 k
Transaction Summary
================================================================================
Install 6 Package(s)
Total download size: 12 M
Installed size: 33 M
Downloading Packages:
(1/6): mysql-5.1.73-3.el6_5.i686.rpm | 903 kB 00:09
(2/6): mysql-devel-5.1.73-3.el6_5.i686.rpm | 129 kB 00:01
(3/6): mysql-libs-5.1.73-3.el6_5.i686.rpm | 1.2 MB 00:20
(4/6): mysql-server-5.1.73-3.el6_5.i686.rpm | 8.8 MB 02:16
(5/6): perl-DBD-MySQL-4.013-3.el6.i686.rpm | 134 kB 00:00
(6/6): perl-DBI-1.609-4.el6.i686.rpm | 705 kB 00:05
--------------------------------------------------------------------------------
Total 69 kB/s | 12 MB 02:56
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.i686 has missing requires of libmysqlclient.so.16
2:postfix-2.6.6-2.2.el6_1.i686 has missing requires of libmysqlclient.so.16(libmysqlclient_16)
2:postfix-2.6.6-2.2.el6_1.i686 has missing requires of mysql-libs
Installing : mysql-libs-5.1.73-3.el6_5.i686 1/6
Installing : mysql-5.1.73-3.el6_5.i686 2/6
Installing : perl-DBI-1.609-4.el6.i686 3/6
Installing : mysql-devel-5.1.73-3.el6_5.i686 4/6
Installing : perl-DBD-MySQL-4.013-3.el6.i686 5/6
Installing : mysql-server-5.1.73-3.el6_5.i686 6/6
Verifying : mysql-server-5.1.73-3.el6_5.i686 1/6
Verifying : perl-DBD-MySQL-4.013-3.el6.i686 2/6
Verifying : mysql-devel-5.1.73-3.el6_5.i686 3/6
Verifying : mysql-5.1.73-3.el6_5.i686 4/6
Verifying : mysql-libs-5.1.73-3.el6_5.i686 5/6
Verifying : perl-DBI-1.609-4.el6.i686 6/6
Installed:
mysql.i686 0:5.1.73-3.el6_5 mysql-devel.i686 0:5.1.73-3.el6_5
mysql-server.i686 0:5.1.73-3.el6_5
Dependency Installed:
mysql-libs.i686 0:5.1.73-3.el6_5 perl-DBD-MySQL.i686 0:4.013-3.el6
perl-DBI.i686 0:1.609-4.el6
Complete!
[root@localhost ~]# rpm -qi mysql-server #查看mysql-sever的安装信息
Name : mysql-server Relocations: (not relocatable)
Version : 5.1.73 Vendor: CentOS
Release : 3.el6_5 Build Date: 2014年02月13日 星期四 03时09分08秒
Install Date: 2014年08月11日 星期一 18时36分25秒 Build Host: c6b9.bsys.dev.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.73-3.el6_5.src.rpm
Size : 25688499 License: GPLv2 with exceptions
Signature : RSA/SHA1, 2014年02月13日 星期四 03时48分04秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://www.mysql.com
Summary : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.
[root@localhost ~]# service mysqld start #启动mysql服务
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[确定]
正在启动 mysqld: [确定]
[root@localhost ~]# service mysqld restart #重启mysql服务
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@localhost ~]# 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.1.73 Source distribution
Copyright (c) 2000, 2013, 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.
[root@TEST ~]# mysqladmin -u root -p password 'root' #修改登录密码
Enter password:
[root@localhost ~]# chkconfig --list| grep mysqld #查看一下mysql服务的端口状态
mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@localhost ~]# chkconfig mysqld on #将mysql服务端口开启
[root@localhost ~]# chkconfig --list| grep mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
附:使用navicat软件进行连接mysql时需要进行的配置
1.在CentOS系统中防火墙默认是阻止3306端口的,我们要是想访问mysql数据库,我们需要这个端口,命令如下:
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
我们需要保存我们的操作,命令如下:
/etc/rc.d/init.d/iptables save
此时我们可以查看端口的状态,命令如下:
/etc/init.d/iptables status
当然如果你打开其他端口也一样,只需要把这个端口号换乘你需要的端口号即可。
2.修改远程连接的权限出现错误的解决方法:
GRANT ALL PRIVILEGES ON *.* TO 'YourUserName'@'%' IDENTIFIED BY "YourPassword";