前言:mysql简介

说到数据库,我们大多想到的是关系型数据库,比如mysql、oracle、sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱不得不首先推荐的是mysql数据库了,而且Mysql数据库的第一个版本就是发行在Linux系统上的。

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL的SQL语言是用于访问数据库的最常用标准化语言。MySQL软件采用了双授权政策(本词条“授权政策”),它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。由于其社区版的性能卓越,搭配PHP和Apache可组成良好的开发环境。

在Linux上安装mysql数据库,我们可以去其官网上下载mysql数据库的rpm包,http://dev.mysql.com/downloads/mysql/5.6.html#downloads,大家可以根据自己的操作系统去下载对应的数据库文件

--->本次是通过yum来进行mysql数据库的安装的,通过这种方式进行安装,可以将跟mysql相关的一些服务、jar包都给我们安装好,能省去很多不必要的麻烦!

一、卸载系统原有mysql

因为mysql数据库在Linux上实在是太流行了,所以目前下载的主流Linux系统版本基本上都集成了mysql数据库在里面

切换到root用户下操作:

[carsonzhu@localhost ~]$ su

查看该操作系统是否已经安装了mysql数据库:

[root@localhost carsonzhu]# rpm -qa | grep mysql

mysql-libs-5.1.71-1.el6.x86_64

然后我用下面的方式试图删除mysql(遇到了问题):

  1. [root@localhost carsonzhu]# rpm -e mysql-libs-5.1.71-1.el6.x86_64
  2. error: Failed dependencies:
  3. libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
  4. libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
  5. mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
  6. [root@localhost carsonzhu]# rpm -e mysql-libs-5.1.71-1.el6.x86_64.rpm --nodeps
  7. error: package mysql-libs-5.1.71-1.el6.x86_64.rpm is not installed

说是卸载的时候有依赖包,需要先把postfix-2:2.6.6-2.2.el6_1.x86_64卸载掉,rpm -e postfix-2:2.6.6-2.2.el6_1.x86_64也是不行!然后我搜索解决方法(CentOS 6.3 64位下彻底卸载mysql5.5.25图解教程)有:

如果存在CentOS自带mysql-libs-5.1.71-1.el6.x86_64使用下面的命令卸载即可

[root@localhost carsonzhu]# rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64
[root@localhost carsonzhu]# rpm -qa|grep -i mysql //查看mysql是否已经卸载成功
发现什么都没有了
[root@localhost carsonzhu]# find / -name mysql //查找之前老版本mysql的目录
发现也没有内容
(注:假设查找结果如下:
[root@localhost ~]# find / -name mysql
# /var/lib/mysql
# /var/lib/mysql/mysql
# /usr/lib64/mysql
删除对应的mysql目录
# rm -rf /var/lib/mysql
# rm -rf /var/lib/mysql
# rm -rf /usr/lib64/mysql
这里卸载后/etc/my.cnf不会删除,需要进行手工删除
# rm -rf /etc/my.cnf)

二、通过yum来安装mysql

查看yum上提供下载的mysql的版本信息:  

  1. [root@localhost carsonzhu]# yum list | grep mysql
  2. apr-util-mysql.x86_64 1.3.9-3.el6_0.1 base
  3. bacula-director-mysql.x86_64 5.0.0-13.el6 base
  4. bacula-storage-mysql.x86_64 5.0.0-13.el6 base
  5. dovecot-mysql.x86_64 1:2.0.9-19.el6_7.2 updates
  6. freeradius-mysql.x86_64 2.2.6-6.el6_7 updates
  7. libdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 base
  8. mod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 base
  9. mysql.x86_64 5.1.73-5.el6_7.1 updates
  10. mysql-bench.x86_64 5.1.73-5.el6_7.1 updates
  11. mysql-connector-java.noarch 1:5.1.17-6.el6 base
  12. mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base
  13. mysql-devel.i686 5.1.73-5.el6_7.1 updates
  14. mysql-devel.x86_64 5.1.73-5.el6_7.1 updates
  15. mysql-embedded.i686 5.1.73-5.el6_7.1 updates
  16. mysql-embedded.x86_64 5.1.73-5.el6_7.1 updates
  17. mysql-embedded-devel.i686 5.1.73-5.el6_7.1 updates
  18. mysql-embedded-devel.x86_64 5.1.73-5.el6_7.1 updates
  19. mysql-libs.i686 5.1.73-5.el6_7.1 updates
  20. mysql-libs.x86_64 5.1.73-5.el6_7.1 updates
  21. mysql-server.x86_64 5.1.73-5.el6_7.1 updates
  22. mysql-test.x86_64 5.1.73-5.el6_7.1 updates
  23. php-mysql.x86_64 5.3.3-46.el6_7.1 updates
  24. qt-mysql.i686 1:4.6.2-28.el6_5 base
  25. qt-mysql.x86_64 1:4.6.2-28.el6_5 base
  26. rsyslog-mysql.x86_64 5.8.10-10.el6_6 base
  27. rsyslog7-mysql.x86_64 7.4.10-3.el6_7.1 updates

然后,可以通过输入 yum install -y mysql-server mysql mysql-devel 命令将mysql mysql-server mysql-devel都安装好(注:安装mysql时并不是安装了mysql客户端就相当于安装好了mysql数据库了,还需要安装mysql-server服务端才行)

等待一番时间后,yum会帮我们选择好安装mysql数据库所需要的软件以及其它附属的一些软件

  1. [root@localhost carsonzhu]# yum install -y mysql-server mysql mysql-deve
  2. Loaded plugins: fastestmirror, refresh-packagekit, security
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.zju.edu.cn
  5. * extras: mirrors.skyshe.cn
  6. * updates: mirrors.skyshe.cn
  7. base | 3.7 kB 00:00
  8. extras | 3.4 kB 00:00
  9. updates | 3.4 kB 00:00
  10. Setting up Install Process
  11. No package mysql-deve available.
  12. Resolving Dependencies
  13. --> Running transaction check
  14. ---> Package mysql.x86_64 0:5.1.73-5.el6_7.1 will be installed
  15. --> Processing Dependency: mysql-libs = 5.1.73-5.el6_7.1 for package: mysql-5.1.73-5.el6_7.1.x86_64
  16. --> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_7.1.x86_64
  17. --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_7.1.x86_64
  18. --> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-5.el6_7.1.x86_64
  19. --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-5.el6_7.1.x86_64
  20. ---> Package mysql-server.x86_64 0:5.1.73-5.el6_7.1 will be installed
  21. --> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-5.el6_7.1.x86_64
  22. --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-5.el6_7.1.x86_64
  23. --> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-5.el6_7.1.x86_64
  24. --> Running transaction check
  25. ---> Package mysql-libs.x86_64 0:5.1.73-5.el6_7.1 will be installed
  26. ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
  27. ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
  28. --> Finished Dependency Resolution
  29.  
  30. Dependencies Resolved
  31.  
  32. ================================================================================
  33. Package Arch Version Repository Size
  34. ================================================================================
  35. Installing:
  36. mysql x86_64 5.1.73-5.el6_7.1 updates 894 k
  37. mysql-server x86_64 5.1.73-5.el6_7.1 updates 8.6 M
  38. Installing for dependencies:
  39. mysql-libs x86_64 5.1.73-5.el6_7.1 updates 1.2 M
  40. perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
  41. perl-DBI x86_64 1.609-4.el6 base 705 k
  42.  
  43. Transaction Summary
  44. ================================================================================
  45. Install 5 Package(s)
  46.  
  47. Total download size: 12 M
  48. Installed size: 33 M
  49. Downloading Packages:
  50. (1/5): mysql-5.1.73-5.el6_7.1.x86_64.rpm | 894 kB 00:00
  51. (2/5): mysql-libs-5.1.73-5.el6_7.1.x86_64.rpm | 1.2 MB 00:01
  52. (3/5): mysql-server-5.1.73-5.el6_7.1.x86_64.rpm | 8.6 MB 00:08
  53. (4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00
  54. (5/5): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:00
  55. --------------------------------------------------------------------------------
  56. Total 1.0 MB/s | 12 MB 00:11
  57. warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
  58. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  59. Importing GPG key 0xC105B9DE:
  60. Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
  61. Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
  62. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  63. Running rpm_check_debug
  64. Running Transaction Test
  65. Transaction Test Succeeded
  66. Running Transaction
  67. Warning: RPMDB altered outside of yum.
  68. ** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
  69. 2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
  70. 2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
  71. 2:postfix-2.6.6-2.2.el6_1.x86_64 has missing requires of mysql-libs
  72. Installing : mysql-libs-5.1.73-5.el6_7.1.x86_64 1/5
  73. Installing : perl-DBI-1.609-4.el6.x86_64 2/5
  74. Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 3/5
  75. Installing : mysql-5.1.73-5.el6_7.1.x86_64 4/5
  76. Installing : mysql-server-5.1.73-5.el6_7.1.x86_64 5/5
  77. Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/5
  78. Verifying : perl-DBI-1.609-4.el6.x86_64 2/5
  79. Verifying : mysql-libs-5.1.73-5.el6_7.1.x86_64 3/5
  80. Verifying : mysql-5.1.73-5.el6_7.1.x86_64 4/5
  81. Verifying : mysql-server-5.1.73-5.el6_7.1.x86_64 5/5
  82.  
  83. Installed:
  84. mysql.x86_64 0:5.1.73-5.el6_7.1 mysql-server.x86_64 0:5.1.73-5.el6_7.1
  85.  
  86. Dependency Installed:
  87. mysql-libs.x86_64 0:5.1.73-5.el6_7.1 perl-DBD-MySQL.x86_64 0:4.013-3.el6
  88. perl-DBI.x86_64 0:1.609-4.el6
  89.  
  90. Complete!

此时,我们通过如下命令查看刚安装好的mysql-server的版本:

  1. [root@localhost carsonzhu]# rpm -qi mysql-server
  2. Name : mysql-server Relocations: (not relocatable)
  3. Version : 5.1.73 Vendor: CentOS
  4. Release : 5.el6_7.1 Build Date: 20160323 星期三 021016
  5. Install Date: 20160522 星期日 143704 Build Host: c6b8.bsys.dev.centos.org
  6. Group : Applications/Databases Source RPM: mysql-5.1.73-5.el6_7.1.src.rpm
  7. Size : 25883011 License: GPLv2 with exceptions
  8. Signature : RSA/SHA1, 20160323 星期三 033621秒, Key ID 0946fca2c105b9de
  9. Packager : CentOS BuildSystem <http://bugs.centos.org>
  10. URL : http://www.mysql.com
  11. Summary : The MySQL server and related files
  12. Description :
  13. MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
  14. client/server implementation consisting of a server daemon (mysqld)
  15. and many different client programs and libraries. This package contains
  16. the MySQL server and some accompanying files and directories.

三、mysql数据库的初始化和相关配置

我们在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是咱们的数据库服务,我们通过输入 service mysqld start 命令就可以启动我们的mysql服务。

:如果是第一次启动mysql服务,mysql服务器首先会进行初始化的配置,如:

  1. [root@localhost carsonzhu]# service mysqld start
  2. 初始化 MySQL 数据库: Installing MySQL system tables...
  3. OK
  4. Filling help tables...
  5. OK
  6.  
  7. To start mysqld at boot time you have to copy
  8. support-files/mysql.server to the right place for your system
  9.  
  10. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  11. To do so, start the server, then issue the following commands:
  12.  
  13. /usr/bin/mysqladmin -u root password 'new-password'
  14. /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
  15.  
  16. Alternatively you can run:
  17. /usr/bin/mysql_secure_installation
  18.  
  19. which will also give you the option of removing the test
  20. databases and anonymous user created by default. This is
  21. strongly recommended for production servers.
  22.  
  23. See the manual for more instructions.
  24.  
  25. You can start the MySQL daemon with:
  26. cd /usr ; /usr/bin/mysqld_safe &
  27.  
  28. You can test the MySQL daemon with mysql-test-run.pl
  29. cd /usr/mysql-test ; perl mysql-test-run.pl
  30.  
  31. Please report any problems with the /usr/bin/mysqlbug script!
  32.  
  33. [确定]
  34. 正在启动 mysqld [确定]

我们会看到第一次启动mysql服务器以后会提示非常多的信息,目的就是对mysql数据库进行初始化操作,再次重启mysql服务时,就不会提示那么多信息了:

  1. [root@localhost carsonzhu]# service mysqld start
  2. 正在启动 mysqld [确定]

查看mysql服务是否为开机自动启动:

  1. [root@localhost carsonzhu]# chkconfig --list | grep mysqld
  2. mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

将其设置为开机启动:

  1. [root@localhost carsonzhu]# chkconfig mysqld on
  2. [root@localhost carsonzhu]# chkconfig --list | grep mysqld
  3. mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

当然,想再次关闭开机启动也很简单:

  1. [root@localhost carsonzhu]# chkconfig mysqld off
  2. [root@localhost carsonzhu]# chkconfig --list | grep mysqld
  3. mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

mysql数据库安装完以后只会有一个root管理员账号,但是此时的root账号还并没有为其设置密码,在第一次启动mysql服务时,会进行数据库的一些初始化工作,在输出的一大串信息中,有这样一行信息 :

  1. /usr/bin/mysqladmin -u root password 'new-password'  // 为root账号设置密码  

设置mysql数据库的root账号((:这个root账号是mysql的root账号,非Linux的root账号)):

  1. [root@localhost carsonzhu]# mysqladmin -u root password 'carsonzhu'

(将root账号密码设置为carsonzhu)  

登录mysql数据库:

  1. [root@localhost carsonzhu]# mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 5
  5. Server version: 5.1.73 Source distribution
  6.  
  7. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql> show databases ;
  16. +--------------------+
  17. | Database |
  18. +--------------------+
  19. | information_schema |
  20. | mysql |
  21. | test |
  22. +--------------------+
  23. 3 rows in set (0.02 sec)
  24.  
  25. mysql>

四、mysql数据库的主要配置文件

1、/etc/my.cnf 是mysql的主配置文件

  1. [root@localhost carsonzhu]# cd
  2. [root@localhost ~]# ls
  3. anaconda-ks.cfg install.log install.log.syslog
  4. [root@localhost ~]# cd /home
  5. [root@localhost home]# ls
  6. carsonzhu
  7. [root@localhost home]# find / -name etc
  8. /usr/local/etc
  9. /usr/lib/vmware-tools/lib32/libconf/etc
  10. /usr/lib/vmware-tools/lib64/libconf/etc
  11. /usr/etc
  12. /usr/share/doc/oddjob-0.30/sample/etc
  13. /usr/share/festival/lib/etc
  14. /usr/lib64/festival/etc
  15. /tmp/vmware-tools-distrib/lib/lib32/libconf/etc
  16. /tmp/vmware-tools-distrib/lib/lib64/libconf/etc
  17. /tmp/vmware-tools-distrib/caf/etc
  18. /tmp/vmware-tools-distrib/etc
  19. /etc
  20. [root@localhost home]# cd /
  21. [root@localhost /]# ls
  22. bin dev lib media net root sr0 tmp var
  23. boot etc lib64 misc opt sbin srv Tools
  24. cdrom home lost+found mnt proc selinux sys usr
  25. [root@localhost /]# cd etc
  1. [root@localhost /]# ls
  2. bin dev lib media net root sr0 tmp var
  3. boot etc lib64 misc opt sbin srv Tools
  4. cdrom home lost+found mnt proc selinux sys usr
  5. [root@localhost /]# cd etc
  6. [root@localhost etc]# ls
  7. abrt hp printcap
  8. acpi httpd profile
  9. adjtime idmapd.conf profile.d
  10. aliases init protocols
  11. aliases.db init.d pulse
  12. alsa inittab purple
  13. alternatives inputrc quotagrpadmins
  14. anacrontab ipa quotatab
  15. anthy-conf iproute2 rc
  16. asound.conf issue rc0.d
  17. at.deny issue.net rc1.d
  18. audisp java rc2.d
  19. audit jvm rc3.d
  20. autofs_ldap_auth.conf jvm-commmon rc4.d
  21. auto.master kde rc5.d
  22. auto.misc kdump-adv-conf rc6.d
  23. auto.net kdump.conf rc.d
  24. auto.smb krb5.conf rc.local
  25. avahi latrace.conf rc.sysinit
  26. bash_completion.d latrace.d readahead.conf
  27. bashrc ld.so.cache redhat-lsb
  28. blkid ld.so.conf redhat-release
  29. bluetooth ld.so.conf.d request-key.conf
  30. bonobo-activation libaudit.conf request-key.d
  31. cas.conf libreport resolv.conf
  32. centos-release libuser.conf rpc
  33. certmonger localtime rpm
  34. chkconfig.d login.defs rsyslog.conf
  35. ConsoleKit logrotate.conf rsyslog.d
  36. cron.d logrotate.d rwtab
  37. cron.daily lsb-release rwtab.d
  38. cron.deny lsb-release.d samba
  39. cron.hourly ltrace.conf sane.d
  40. cron.monthly lvm sasl2
  41. crontab magic scl
  42. cron.weekly mailcap securetty
  43. crypttab mail.rc security
  44. csh.cshrc makedev.d selinux
  45. csh.login man.config services
  46. cups maven sestatus.conf
  47. dbus-1 mime.types setuptool.d
  48. default mke2fs.conf sgml
  49. depmod.d modprobe.d shadow
  50. dhcp motd shadow-
  51. DIR_COLORS mtab shells
  52. DIR_COLORS.256color mtools.conf skel
  53. DIR_COLORS.lightbgcolor my.cnf smartd.conf
  54. dnsmasq.conf nanorc snmp
  55. dnsmasq.d netconfig sos.conf
  56. dracut.conf NetworkManager sound
  57. dracut.conf.d networks ssh
  58. drirc nfsmount.conf ssl
  59. enscript.cfg nsswitch.conf sssd
  60. environment ntp statetab
  61. ethers ntp.conf statetab.d
  62. event.d obex-data-server sudo.conf
  63. exports oddjob sudoers
  64. favicon.png oddjobd.conf sudoers.d
  65. festival oddjobd.conf.d sudo-ldap.conf
  66. filesystems openldap sysconfig
  67. fonts opt sysctl.conf
  68. foomatic PackageKit system-release
  69. fprintd.conf pam.d system-release-cpe
  70. fstab pango terminfo
  71. gai.conf passwd tpvmlp.conf
  72. gconf passwd- Trolltech.conf
  73. gcrypt pbm2ppa.conf udev
  74. gdm pcmcia updatedb.conf
  75. ghostscript pinforc vimrc
  76. gnome-vfs-2.0 pkcs11 virc
  77. gnupg pki vmware-caf
  78. group plymouth vmware-tools
  79. group- pm warnquota.conf
  80. grub.conf pm-utils-hd-apm-restore.conf wgetrc
  81. gshadow pnm2ppa.conf wpa_supplicant
  82. gshadow- polkit-1 X11
  83. gssapi_mech.conf popt.d xdg
  84. gtk-2.0 portreserve xinetd.d
  85. hal postfix xml
  86. host.conf ppp yp.conf
  87. hosts prelink.cache yum
  88. hosts.allow prelink.conf yum.conf
  89. hosts.deny prelink.conf.d yum.repos.d
  1. [root@localhost etc]# ls my.cnf
  2. my.cnf
  3. [root@localhost etc]# cat my.cnf
  4. [mysqld]
  5. datadir=/var/lib/mysql
  6. socket=/var/lib/mysql/mysql.sock
  7. user=mysql
  8. # Disabling symbolic-links is recommended to prevent assorted security risks
  9. symbolic-links=0
  10.  
  11. [mysqld_safe]
  12. log-error=/var/log/mysqld.log
  13. pid-file=/var/run/mysqld/mysqld.pid

2、/var/lib/mysql   mysql数据库的数据库文件存放位置

  1. [root@localhost etc]# cd /var
  2. [root@localhost var]# cd lib/mysql
  3. [root@localhost mysql]# ls -1
  4. ibdata1
  5. ib_logfile0
  6. ib_logfile1
  7. mysql //mysql数据库安装时默认的两个数据库文件
  8. mysql.sock
  9. test //mysql数据库安装时默认的两个数据库文件

自己创建一个数据库,并验证该数据库文件的存放位置:

  1. [root@localhost mysql]# mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 6
  5. Server version: 5.1.73 Source distribution
  6.  
  7. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql> create database carsontest ;
  16. Query OK, 1 row affected (0.01 sec)
  17.  
  18. mysql> exit
  19. Bye
  20. [root@localhost mysql]# ls -1
  21. carsontest
  22. ibdata1
  23. ib_logfile0
  24. ib_logfile1
  25. mysql
  26. mysql.sock
  27. test
  28. [root@localhost mysql]# cd carsontest
  29. [root@localhost carsontest]# ls
  30. db.opt

3、/var/log mysql数据库的日志输出存放位置

  1. [root@localhost carsontest]# cd
  2. [root@localhost ~]# cd /var/log
  3. [root@localhost log]# ls
  4. anaconda.ifcfg.log gdm secure-20160517
  5. anaconda.log httpd secure-20160522
  6. anaconda.program.log lastlog spice-vdagent.log
  7. anaconda.storage.log maillog spooler
  8. anaconda.syslog maillog-20160305 spooler-20160305
  9. anaconda.xlog maillog-20160517 spooler-20160517
  10. anaconda.yum.log maillog-20160522 spooler-20160522
  11. audit messages sssd
  12. boot.log messages-20160305 tallylog
  13. btmp messages-20160517 vmware-caf
  14. btmp-20160517 messages-20160522 vmware-install.log
  15. ConsoleKit mysqld.log vmware-vmsvc.log
  16. cron ntpstats wpa_supplicant.log
  17. cron-20160305 pm-powersave.log wtmp
  18. cron-20160517 ppp Xorg.0.log
  19. cron-20160522 prelink Xorg.0.log.old
  20. cups sa Xorg.9.log
  21. dmesg samba yum.log
  22. dmesg.old secure
  23. dracut.log secure-20160305

因为我们的mysql数据库是可以通过网络访问的,并不是一个单机版数据库,其中使用的协议是 tcp/ip 协议,我们都知道mysql数据库绑定的端口号是 3306 ,所以我们可以通过 netstat -anp 命令来查看一下,Linux系统是否在监听 3306 这个端口号:

  1. [root@localhost log]# netstat -anp | more
  2. Active Internet connections (servers and established)
  3. Proto Recv-Q Send-Q Local Address Foreign Address
  4. State PID/Program name
  5. tcp 0 0 0.0.0.0:38029 0.0.0.0:*
  6. LISTEN 1788/rpc.statd
  7. tcp 0 0 0.0.0.0:111 0.0.0.0:*
  8. LISTEN 1742/rpcbind
  9. tcp 0 0 0.0.0.0:22 0.0.0.0:*
  10. LISTEN 1961/sshd
  11. tcp 0 0 127.0.0.1:631 0.0.0.0:*
  12. LISTEN 1845/cupsd
  13. tcp 0 0 127.0.0.1:25 0.0.0.0:*
  14. LISTEN 2131/master
  15. tcp 0 0 0.0.0.0:3306 0.0.0.0:*
  16. LISTEN 20295/mysqld
  17. tcp 1 0 192.168.1.20:53892 61.213.168.17:80
  18. CLOSE_WAIT 2723/clock-applet
  19. tcp 1 0 192.168.1.20:53891 61.213.168.17:80
  20. CLOSE_WAIT 2723/clock-applet
  21. tcp 0 0 :::40843 :::*
  22. LISTEN 1788/rpc.statd
  23. tcp 0 0 :::111 :::*
  24. LISTEN 1742/rpcbind

结果如上所示,Linux系统监听的3306端口号就是我们的mysql数据库!

可参考文章:Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

另外一种安装方式:CentOS7安装mysql5.6.26

  

  

  

  

  

  

  

 

  

  

  

  

  

  

  

linux学习之centos(三):mysql数据库的安装和配置的更多相关文章

  1. Linux学习之CentOS6下Mysql数据库的安装与配置

    转自:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

  2. Linux学习之CentOS--CentOS6.下Mysql数据库的安装与配置

    跟着配置,顺利配置完成 http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html

  3. CentOS 下Mysql数据库的安装与配置

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常 的方便,在Linux上如果要安装数据库, ...

  4. linux应用之mysql数据库的安装及配置(centos)

    CentOS下Mysql数据库的安装与配置   如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲 ...

  5. Linux学习之CentOS(三)--初识linux的文件系统以及用户组等概念

    Linux学习之CentOS(三)--初识linux的文件系统以及用户组等概念 进入到了Linux学习之CentOS第三篇了,这篇文章主要记录下对linux文件系统的初步认识,以及用户组.用户权限.文 ...

  6. MySQL数据库的安装与配置(windows)

    MySQL是目前最为流行的开放源码的数据库,是完全网络化的跨平台的关系型数据库系统,它是由瑞典MySQLAB公司开发,目前属于Oracle公司.任何人都能从Internet下载MySQL软件,而无需支 ...

  7. mysql数据库的安装与配置

    mysql数据库的安装与配置及workbench的简单使用 mysql数据库社区版下载:https://dev.mysql.com/downloads/installer/ 我这里选的是社区安装版(适 ...

  8. [转] Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    from:  http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得 ...

  9. Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    原文:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

随机推荐

  1. [luogu 5300][bzoj 5502] [GXOI/GZOI2019] 与或和

    题面 思路还是挺容易想的, 只是由于我还是太\(naive\)了一点不会做只会打暴力吧...... 题目要我们求所有子矩阵的\(and\)值之和与\(or\)值之和, 一看之下似乎不好入手, 我们慢慢 ...

  2. 20145236《网络攻防》Exp4 恶意代码分析

    20145236<网络攻防>Exp4 恶意代码分析 一.基础问题回答 如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么.请设计下你想监控的操作有哪些 ...

  3. activemq5.14+zookeeper3.4.9实现高可用

    一.activeMQ主要的几类部署方式比较1.默认的单机部署(kahadb)activeMQ的默认存储的单机方式,以本地kahadb文件的方式存储,所以性能指标完全依赖本地磁盘IO,不能提供高可用. ...

  4. Linux系统学习之文件管理

    Linux目录分布通常是树形,所以它的结构又称为目录树. 一.文件和目录管理 [root@Cfhost-170820-UCNK /]# cd / [root@Cfhost-170820-UCNK /] ...

  5. Python基础(4)列表、元组、字符串、字典、集合、文件操作

    列表.元组操作 字符串操作 字典操作 集合操作 文件操作 字符编码与转码 详见:http://www.cnblogs.com/alex3714/articles/5717620.html 1.列表和元 ...

  6. WebSockets通信

    WebSockets通信 1. websocket是什么?WebSocket是一种网络通信协议.2. 为什么需要websocket?我们有http协议,为什么还需要websocket协议呢?因为htt ...

  7. git排错

    解决: 将远程仓库中除.git以外的所有文件删除,然后执行   git config --bool core.bare true  然后客户端重新push即可解决问题 还要注意远程仓库权限方面...

  8. ubuntu 14.04 sudo apt-get 简单 安装 ffmpeg

    一种方法是这样的sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next sudo apt-get update sudo apt-get in ...

  9. windows平台快速搭建Linux(CentOS)

    VMware简介 VMware Workstation(简称 “虚拟机”)是一款功能强大的桌面虚拟计算机软件,用户可在Windows平台通过VMware软件同时运行不同的操作系统.这对IT开发人员而言 ...

  10. Intel x86_64 Architecture Background 3

    多层次的cache结构解决了CPU和DRAM之间处理速度不一致的问题,在Intel体系架构下,CPU核心和主存DRAM之间有着三层的cache.其中一层缓存L1和二层缓存L2在CPU核心(core)中 ...