工作好多年了,也从事过不同行业的软件研发,做了不少项目,却没有怎么记录自己在工作中碰到的问题。
1、查看下操作系统信息
lsb_release -a
这两个命令都可以查看操作信息信息
cat /etc/issue
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
2、用yum命令安装MySql
yum -y install mysql-server
大家可以在用yum命令安装的时候回碰到类似的报错信息,
Error Downloading Packages:
mysql-server-5.1.73-7.el6.x86_64: failure: Packages/mysql-server-5.1.73-7.el6.x86_64.rpm from base: [Errno 256] No moremirrors to try.
mysql-5.1.73-7.el6.x86_64: failure: Packages/mysql-5.1.73-7.el6.x86_64.rpm from base: [Errno 256] No moremirrors to try.
mysql-libs-5.1.73-7.el6.x86_64: failure: Packages/mysql-libs-5.1.73-7.el6.x86_64.rpm from base: [Errno 256] No moremirrors to try.perl-DBD-MySQL-4.013-3.el6.x86_64: failure: Packages/perl-DBD-MySQL-4.013-3.el6.x86_64.rpm from base: [Errno 256] No moremirrors to try.perl-DBI-1.609-4.el6.x86_64: failure: Packages/perl-DBI-1.609-4.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.
这个需要更新yum命令,执行命令即可
1 yumclean all2
3 yum makecache
3、设置开机启动MySql
chkconfig mysqld on
4、通过命令可以查看刚安装的mysql版本信息
rpm -qi mysql-server
[root@iZ9489q4bybZ opt]# rpm -qi mysql-server
Name : mysql-server Relocations: (not relocatable)
Version : 5.1.73 Vendor: CentOS
Release : 7.el6 Build Date: Wed 11 May 2016 02:31:38 PM CST
Install Date: Tue 07 Jun 2016 03:33:38 PM CST Build Host: worker1.bsys.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.73-7.el6.src.rpm
Size : 25883075 License: GPLv2 with exceptions
Signature : RSA/SHA1, Thu 12 May 2016 06:49:52 PM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem
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.
5、首次执行命令,会显示初始化的一些信息
1 service mysqld start
[root@iZ9489q4bybZ opt]# service mysqld start
Initializing MySQL database: 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 iZ9489q4bybZ 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!
[ OK ]
Starting mysqld: [ OK ]
6、对应的重启命令
service mysqld restart
7、检查Mysql的服务开启项
chkconfig --list | grep mysqld
[root@iZ9489q4bybZ opt]# chkconfig --list | grep mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
8、给客户端赋权限
1 给用户root赋权限(password为root的password)
grant all privileges on *.* to 'root'@'%' identified by 'password'with grant option;2
刷新权限
3 flush privileges;