码迷,mamicode.com
首页 > 数据库 > 详细

Linux MySQL

时间:2016-07-13 12:10:52      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:linux m

安装

提示:前面的步骤和Apache安装一样,可参鉴Apache安装。

####################################################

编译出现的错误:

checking for termcap functions library... configure: error: Nocurses/termcap library found

解决办法:

安装:yum -y install ncurses-devel

扩展:解决办法(http://blog.csdn.net/zccst/article/details/4493074

出现这说明编译成功:Thank you for choosing MySQL!

安装mysql后需要出初始化

[root@zyl mysql-5.1.72]# cd/home/oldboy/tools/mysql-5.1.72/support-files/my*

-rw-r--r-- 1 root root   4746 Jul  8 16:07 support-files/my-huge.cnf

-rw-r--r-- 1 7155 wheel  4698 Sep10  2013 support-files/my-huge.cnf.sh

-rw-r--r-- 1 root root  19779Jul  8 16:07support-files/my-innodb-heavy-4G.cnf

-rw-r--r-- 1 7155 wheel 19759 Sep 10 2013 support-files/my-innodb-heavy-4G.cnf.sh

-rw-r--r-- 1 root root   4720Jul  8 16:07 support-files/my-large.cnf

-rw-r--r-- 1 7155 wheel  4672 Sep10  2013 support-files/my-large.cnf.sh

-rw-r--r-- 1 root root   4731Jul  8 16:07 support-files/my-medium.cnf

-rw-r--r-- 1 7155 wheel  4683 Sep10  2013 support-files/my-medium.cnf.sh

-rw-r--r-- 1 root root   2499Jul  8 16:07 support-files/my-small.cnf

-rw-r--r-- 1 7155 wheel  2451 Sep10  2013 support-files/my-small.cnf.sh

-rw-r--r-- 1 root root  69612Jul  8 16:07support-files/mysql-5.1.72.spec

-rw-r--r-- 1 root root   1061Jul  8 16:07support-files/mysqld_multi.server

-rw-r--r-- 1 7155 wheel  1061 Sep10  2013support-files/mysqld_multi.server.sh

-rw-r--r-- 1 root root    879Jul  8 16:07 support-files/mysql-log-rotate

-rw-r--r-- 1 7155 wheel   791 Sep10  2013support-files/mysql-log-rotate.sh

-rw-r--r-- 1 7155 wheel  4187 Sep10  2013 support-files/mysql.m4

-rw-r--r-- 1 root root  12581Jul  8 16:07 support-files/mysql.server

-rw-r--r-- 1 7155 wheel 12477 Sep 10 2013 support-files/mysql.server.sh

-rw-r--r-- 1 root root  69612Jul  8 16:07 support-files/mysql.spec

-rw-r--r-- 1 7155 wheel 69703 Sep 10 2013 support-files/mysql.spec.sh

[root@zyl mysql-5.1.72]# llsupport-files/my*.cnf  数据库的配置文件

-rw-r--r-- 1 root root  4746 Jul  8 16:07 support-files/my-huge.cnf

-rw-r--r-- 1 root root 19779 Jul  816:07 support-files/my-innodb-heavy-4G.cnf

-rw-r--r-- 1 root root  4720 Jul  8 16:07 support-files/my-large.cnf

-rw-r--r-- 1 root root  4731 Jul  8 16:07 support-files/my-medium.cnf  

-rw-r--r-- 1 root root  2499 Jul  8 16:07 support-files/my-small.cnf   

[root@zyl mysql-5.1.72]#cd support-files/

 [root@zyl support-files]# cp my-small.cnf (mysql的文件名) /etc/my.cnf /etc/my.cnf   因为这是mysql的默认路径

cp: overwrite `/etc/my.cnf‘? y

[root@zyl support-files]# less /etc/my.cnf

# Example MySQL config file for small systems.

#

# This is for a system with little memory (<= 64M) where MySQL is onlyused

# from time to time and it‘s important that the mysqld daemon

# doesn‘t use much resources.

#

# MySQL programs look for option files in a set of

# locations which depend on the deployment platform.

# You can copy this option file to one of those

# locations. For information about these locations, see:

# http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

 

# The following options will be passed to all MySQL clients

[client]

。。。。。。。。。。。。。。。

[root@zyl support-files]# mkdir /application/mysql/data -p 这是mysql存放的数据的路径

[root@zyl support-files]# ll /application/mysql/data/

total 0  ====

[root@zyl support-files]#/application/mysql/bin/mysql_install_db -–basedir=/application/mysql--datadir=/application/mysql/data/ --user=mysql

WARNING: The host ‘zyl‘ 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...

160708 21:30:42 [Warning] ‘--skip-locking‘ isdeprecated and will be removed in a future release. Please use‘--skip-external-locking‘ instead.

OK                                 

Filling help tables...

160708 21:30:42 [Warning]‘--skip-locking‘ is deprecated and will be removed in a future release. Pleaseuse ‘--skip-external-locking‘ instead.

OK

    判断是否成功:没有出现错误,警告不理他;出现两个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:

 

/application/mysql/bin/mysqladmin -uroot password ‘new-password  创建密码

/application/mysql/bin/mysqladmin -u root -h zyl password ‘new-password‘

 

Alternatively you can run:

/application/mysql/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 /application/mysql ; /application/mysql/bin/mysqld_safe&

 

You can test the MySQL daemon with mysql-test-run.pl

cd /application/mysql/mysql-test ; perl mysql-test-run.pl

 

Please report any problems with the /application/mysql/scripts/mysqlbugscript!

 

初始化完成。

[root@zyl support-files]# ll/application/mysql/data/

total 8

drwx------ 2 mysql root 4096 Jul  821:30 mysql

drwx------ 2 mysql root 4096 Jul  821:30 test

[root@zyl support-files]# tree /application/mysql/data/

/application/mysql/data/

├── mysql

│   ├── columns_priv.frm

│   ├── columns_priv.MYD

│   ├── columns_priv.MYI

│   ├── db.frm

│   ├── db.MYD

│   ├── db.MYI

│   ├── event.frm

│   ├── event.MYD

│   ├── event.MYI

│   ├── func.frm

│   ├── func.MYD

│   ├── func.MYI

│   ├── general_log.CSM

│   ├── general_log.CSV

│   ├── general_log.frm

│   ├── help_category.frm

│   ├── help_category.MYD

│   ├── help_category.MYI

│   ├── help_keyword.frm

│   ├── help_keyword.MYD

│   ├── help_keyword.MYI

│   ├── help_relation.frm

│   ├── help_relation.MYD

│   ├── help_relation.MYI

│   ├── help_topic.frm

│   ├── help_topic.MYD

│   ├── help_topic.MYI

│   ├── host.frm

│   ├── host.MYD

│   ├── host.MYI

│   ├── ndb_binlog_index.frm

│   ├── ndb_binlog_index.MYD

│   ├── ndb_binlog_index.MYI

│   ├── plugin.frm

│   ├── plugin.MYD

│   ├── plugin.MYI

│   ├── proc.frm

│   ├── proc.MYD

│   ├── proc.MYI

│   ├── procs_priv.frm

│   ├── procs_priv.MYD

│   ├── procs_priv.MYI

│   ├── servers.frm

│   ├── servers.MYD

│   ├── servers.MYI

│   ├── slow_log.CSM

│   ├── slow_log.CSV

│   ├── slow_log.frm

│   ├── tables_priv.frm

│   ├── tables_priv.MYD

│   ├── tables_priv.MYI

│   ├── time_zone.frm

│   ├── time_zone_leap_second.frm

│   ├── time_zone_leap_second.MYD

│   ├── time_zone_leap_second.MYI

│   ├── time_zone.MYD

│   ├── time_zone.MYI

│   ├── time_zone_name.frm

│   ├── time_zone_name.MYD

│   ├── time_zone_name.MYI

│   ├── time_zone_transition.frm

│   ├── time_zone_transition.MYD

│   ├── time_zone_transition.MYI

│   ├──time_zone_transition_type.frm

│   ├──time_zone_transition_type.MYD

│   ├──time_zone_transition_type.MYI

│   ├── user.frm

│   ├── user.MYD

│   └── user.MYI

└── test

 

2 directories, 69 files

[root@zyl support-files]#

出现的错误

1.mysql不能被解析

技术分享

2.不能再/tmp下创建文件

技术分享

解决办法:

技术分享

 

启动数据库

[root@zyl support-files]# cp mysql.server.sh /etc/init.d/mysqld   启动脚本

cp: overwrite `/etc/init.d/mysqld‘? y

[root@zyl support-files]#chkconfig  --add  mysqld

[root@zyl support-files]#chkconfig  mysqld on

[root@zyl support-files]# /etc/init.d/mysqld

-bash: /etc/init.d/mysqld: Permissiondenied

[root@zyl support-files]# chmod  +x /etc/init.d/mysqld            

[root@zyl support-files]#/etc/init.d/mysqld          

/etc/init.d/mysqld: line 260:my_print_defaults: command not found

/etc/init.d/mysqld: line 263:my_print_defaults: command not found

/etc/init.d/mysqld: line 270:@HOSTNAME@: command not found

/etc/init.d/mysqld: line 279:@HOSTNAME@: command not found

Usage: /etc/init.d/mysqld  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]

[root@zyl support-files]#/etc/init.d/mysqld start

/etc/init.d/mysqld: line 260:my_print_defaults: command not found

/etc/init.d/mysqld: line 263:my_print_defaults: command not found

/etc/init.d/mysqld: line 270:@HOSTNAME@: command not found

/etc/init.d/mysqld: line 279:@HOSTNAME@: command not found

/etc/init.d/mysqld: line 292:cd: @prefix@: No such file or directory

Starting MySQL ERROR! Couldn‘tfind MySQL manager (@bindir@/mysqlmanager) or server (@bindir@/mysqld_safe)

启动不了!!!!!!!! 解决方法:

[root@zyl support-files]#

[root@zyl support-files]# /application/mysql/bin/mysqld_safe& ===== 后台启动

[1] 54281

[root@zyl support-files]# 160708 21:55:31 mysqld_safe Logging to ‘/application/mysql5.1.72/data/zyl.err‘.

160708 21:55:32 mysqld_safe Starting mysqld daemon with databases from/application/mysql5.1.72/data

[root@zyl support-files]# netstat -lnput|grep mysql

tcp        0      0 0.0.0.0:3306 (数据库的端口)               0.0.0.0:*                   LISTEN      54389/mysqld       

启动mysal:

root@zyl support-files]# mysql   

-bash: mysql: commandnot found   是因为mysql不在pash 路径

启动法一: 全路径启动

[root@zyl support-files]# /application/mysql/bin/mysql

Welcome to the MySQL monitor.  Commandsend with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.72 Source distribution

 

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rightsreserved.

 

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 inputstatement.

 

mysql> quit

Bye

启动法二:

[root@zyl support-files]# vi /etc/profile

。。。。。。。。。。。

done

 

unset i

unset -f pathmunge

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

alias grep=‘grep --color=auto‘

"/etc/profile" 81L, 1938C written

[root@zyl support-files]#

[root@zyl support-files]# grep mysql /etc/profile

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

[root@zyl support-files]# . /etc/profile   生效   =  [root@zyl support-files]# source /etc/profile

[root@zyl support-files]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.1.72 Source distribution

 

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rightsreserved.

 

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 | ============================è》》》》系统自动管理,不需要管理员管理

| mysql              |

| test               |

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

3 rows in set (0.00 sec)

mysql>

第一种方法:

启动:

/application/mysql/bin/mysqld_safe &

关闭:

mysqladmin shutdown

 

第二种:

/etc/init.d/mysqld start

/etc/init.d/mysqld stop

混合用有问题:

 

给数据库添加密码

[root@zyl support-files]# /application/mysql/bin/mysqladmin -u rootpassword ‘oldboy123

[root@zyl support-files]# mysql

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (usingpassword: NO)  =====需要密码

[root@zyl support-files]# mysql-uroot -p

Enter password: ===========输入密码

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.72 Source distribution

 

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rightsreserved.

 

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 inputstatement.

 

mysql>

mysql> showdatabases;

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

| Database           |

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

| information_schema |

| mysql              |

| test               |

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

3 rows in set (0.00 sec)

 

mysql> selectversion();   查看版本

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

| version() |

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

| 5.1.72    |

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

1 row in set (0.00 sec)

 

mysql> selectuser();    查看用户

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

| user()         |

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

| root@localhost |

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

1 row in set (0.00 sec)

 

mysql>

 

mysql> dropdatabase test;  删除test

Query OK, 0 rows affected (0.02 sec)

 

mysql> show  databases;  

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

| Database           |

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

| information_schema |

| mysql              |

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

2 rows in set (0.00 sec)

mysql> select user,host from mysql.user;

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

| user | host      |

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

| root | 127.0.0.1 |

|      | localhost |

| root | localhost |

|      | zyl       |

| root | zyl       |

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

5 rows in set (0.00 sec)

mysql> selectuser,host from mysql.user;

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

| user | host      |

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

| root | 127.0.0.1 |

|      | localhost |   

| root | localhost |

|      | zyl       |

| root | zyl       |

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

5 rows in set (0.00 sec)

 

mysql> drop user""@zyl;

Query OK, 0 rows affected (0.00 sec)

 

mysql> drop user""@localhost;

Query OK, 0 rows affected (0.00 sec)

 

mysql> selectuser,host from mysql.user;

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

| user | host      |

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

| root | 127.0.0.1 |

| root | localhost |

| root | zyl       |

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

3 rows in set (0.00 sec)

 

mysql>

 


本文出自 “zhangyiling” 博客,转载请与作者联系!

Linux MySQL

标签:linux m

原文地址:http://813415154.blog.51cto.com/10900500/1825912

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!