首页 > 数据库技术 > 详细

mysql 数据库的安装之 二 二进制安装

时间:2017-01-12 16:34:51      阅读:42      评论:0      收藏:0      [点我收藏+]

标签:mysql 二进制安装

#二进制安装mysql,直接解压初始化数据库就可以了

1.创建用户和组

[root@Lnmp tools]#useradd mysql -s /sbin/nologin/ -M

2.解压安装包

[root@Lnmp tools]#tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz 


[root@Lnmp tools]#mv mysql-5.5.32-linux2.6-x86_64 mysql

[root@Lnmp tools]#mv mysql /application/ 

#独立安装数据库到此结束。

[root@Lnmp tools]# mkdir -p /application/mysql/data/


[root@Lnmp tools]#chown -R mysql.mysql /application/mysql/data


3.初始化数据库

[root@Lnmp tools]# cd /application/mysql/

[root@Lnmp mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/

WARNING: The host ‘Lnmp‘ could not be looked up with resolveip.

This probably means that your libc libraries are not 100 % compatible

with this binary MySQL version. The MySQL daemon, mysqld, should work

normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK


[root@Lnmp mysql]# \cp support-files/mysql.server /etc/init.d/mysqld


[root@Lnmp mysql]#cp support-files/my-small.cnf /etc/my.cnf  #指定配置文件


#如果不指定则,启动时出现:

ERROR 2002 (HY000):Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock/(2)


4.启动Mysql:

[root@Lnmp mysql]# /etc/init.d/mysqld start 

/etc/init.d/mysqld: line 276: cd: /usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

如果不成功则修改下面:

[root@Lnmp mysql]# vi /etc/init.d/mysqld  +46

basedir=/application/mysql

datadir=/application/mysql/data


[root@Lnmp mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS! 


#登录

#mysql

出现下面错误:

#-bash:mysql:command not found

mysql 对应的路径不在path目录下面

使用全路径进入mysql:

/application/mysql/bin/mysql

或者在文件最后加上:

vi /etc/profile

PATH="/application/mysql/bin/:$PATH"

#. /etc/profile   #使之生效

mysql>


#设置密码,不要在mysql>  下面设置密码,在#后面设置密码

/application/mysql/bin/mysqladmin -u  root password ‘passwd123‘

#重新登录


mysql -u root -p

passwd123


5.数据优化:

select version();         #查看数据库版本

select user();            #查看当前的用户

mysql> show databases;    #查看数据库

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+


mysql>drop database test; #安全设置,删除没有用的数据库

#最终优化为:

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

mysql> select user,host from mysql.user;  #查询表中的用户

+------+-----------+

| user | host      |

+------+-----------+

| root | 127.0.0.1 |

| root | ::1       |

|      | Lnmp      |

| root | Lnmp      |

|      | localhost |

| root | localhost |

+------+-----------+

mysql>delete from mysql.user where(host="Lnmp");

mysql>delete from mysql.user where(host="::1");

mysql> drop user ""@localhost;

#最终优化为:

mysql> select user,host from mysql.user;

+------+-----------+

| user | host      |

+------+-----------+

| root | 127.0.0.1 |

| root | localhost |

+------+-----------+

最后:

flush privileges;


本文出自 “知识改变命运” 博客,请务必保留此出处http://ahtornado.blog.51cto.com/4826737/1891264

mysql 数据库的安装之 二 二进制安装

标签:mysql 二进制安装

原文:http://ahtornado.blog.51cto.com/4826737/1891264

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号