Mysql试水

如今年代,数据处理挖掘一浪高过一浪,nosql一会出来一个新的,对于一个数据库小白来说,不努力钻研点,感觉脱离了这个时代的感觉,nosql还没到那步,感觉拿耳濡目染的mysql来练练手学习下基本知识应该还是靠谱点,决定每天挖点点

印象中linux下涉及到mysql的,好像都要经历一番配置,很多人习惯windows下的无脑dps,一个exe直接下一步到结束,而且很少出现版本依赖问题,而linux的出世就是在一群带着严格版本号的东西凑合起来的,导致如今linux下安装个东西还是会出现对依赖的版本限制,虽然不知道到底这样是好还是坏,但是搞linux的肯定是好男人

偷偷懒,仗着cygwin安装方便,直接选定mysql,全部install,看着还有人源代码来编译新版本mysql,由衷佩服,任何能在cygwin上编译一个大型软件的人,的确是有耐心,有能力

按照linux上说的启动方法:

lihui@2015 ~
$ mysql -u root mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/r/mysql.sock’ (2)

好吧,直接错误,搜索下cygwin如何启动

lihui@2015 ~
$ mysql -h 127.0.0.1 -u root -p
Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)

好吧,看来东西不全

##############################分割线##############################

换到linux上继续进行,先瞧一瞧:

[lihui@localhost ~]$ yum list | grep mysql
mysql.x86_64                            5.1.73-3.el6_5                   @base 
mysql-libs.x86_64                       5.1.73-3.el6_5                   @base 
apr-util-mysql.x86_64                   1.3.9-3.el6_0.1                  base  
bacula-director-mysql.x86_64            5.0.0-12.el6                     base  
bacula-storage-mysql.x86_64             5.0.0-12.el6                     base  
dovecot-mysql.x86_64                    1:2.0.9-8.el6_6.4                updates
freeradius-mysql.x86_64                 2.1.12-6.el6                     base  
libdbi-dbd-mysql.x86_64                 0.8.3-5.1.el6                    base  
mod_auth_mysql.x86_64                   1:3.0.0-11.el6_0.1               base  
mysql-bench.x86_64                      5.1.73-3.el6_5                   base  
mysql-connector-java.noarch             1:5.1.17-6.el6                   base  
mysql-connector-odbc.x86_64             5.1.5r1144-7.el6                 base  
mysql-devel.i686                        5.1.73-3.el6_5                   base  
mysql-devel.x86_64                      5.1.73-3.el6_5                   base  
mysql-embedded.i686                     5.1.73-3.el6_5                   base  
mysql-embedded.x86_64                   5.1.73-3.el6_5                   base  
mysql-embedded-devel.i686               5.1.73-3.el6_5                   base  
mysql-embedded-devel.x86_64             5.1.73-3.el6_5                   base  
mysql-libs.i686                         5.1.73-3.el6_5                   base  
mysql-server.x86_64                     5.1.73-3.el6_5                   base  
mysql-test.x86_64                       5.1.73-3.el6_5                   base  
php-mysql.x86_64                        5.3.3-40.el6_6                   updates
qt-mysql.i686                           1:4.6.2-28.el6_5                 base  
qt-mysql.x86_64                         1:4.6.2-28.el6_5                 base  
rsyslog-mysql.x86_64                    5.8.10-10.el6_6                  updates
rsyslog7-mysql.x86_64                   7.4.10-3.el6_6                   updates

还不少,需要server服务端,mysql,以及devel应该就行了

[lihui@localhost ~]$ sudo yum install mysql mysql-server mysql-devel

安装完之后,发现了开机启动脚本,这下就有戏了:

[lihui@localhost ~]$ ll /etc/init.d/mysqld
-rwxr-xr-x. 1 root root 7026 Feb 13  2014 /etc/init.d/mysqld

直接通过service启动:

[lihui@localhost ~]$ sudo service mysqld start
Initializing MySQL database:  Installing MySQL system tables…
OK
Filling help tables…
OK

…………….中间省略一些初始化工作……………..

Starting mysqld:                                           [  OK  ]

登录数据库瞧瞧:

[lihui@localhost ~]$ mysql -u lihui
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
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.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| test               |
+——————–+
2 rows in set (0.07 sec)

mysql>

但是在第一次启动,初始化的时候有如下信息:

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’

也就是给数据库设置一个root密码,但这里的root并不是linux系统的root,至于这些细节,慢慢再研究吧~!

发表评论