您的位置:首页 > 运维架构 > Linux

linux下安装mysql

2012-02-21 11:00 357 查看
系统 Red Hat 企业版5

将mysql-5.1.55.tar.gz上传至linux服务器/usr/local路径下

[root@pgb203 local]# ls mysql-5.1.55.tar.gz

mysql-5.1.55.tar.gz //返回此提示证明软件已在/usr/local路径下

[root@pgb203 local]# groupadd -r mysql

[root@pgb203 local]# useradd -g mysql -r mysql

[root@pgb203 local]# gunzip < mysql-5.1.55.tar.gz | tar -xvf -

[root@pgb203 local]# cd mysql-5.1.55

[root@pgb203 mysql-5.1.55]#./configure –prefix=/usr/local/mysql/ //安装路径为/usr/local/mysql

[root@pgb203 mysql-5.1.55]# make

[root@pgb203 mysql-5.1.55]# make install

[root@pgb203 mysql-5.1.55]#cd /usr/local/mysql/

[root@pgb203 mysql]#chown -R mysql .

[root@pgb203 mysql]# chgrp -R mysql .

[root@pgb203 mysql]#/usr/local/mysql/bin/mysql_install_db --user=mysql

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/local/mysql/bin/mysqladmin -u root password 'new-password'

/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

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

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

cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

[root@pgb203 mysql]# chown -R root .

[root@pgb203 mysql]# cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf

[root@pgb203 mysql]# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql.server

[root@pgb203 mysql]#./bin/mysqld_safe --user=mysql &

[root@pgb203 mysql]# chown -R mysql /usr/local/mysql/var/

[root@pgb203 mysql]#/usr/local/mysql/bin/mysql -V
//检查mysql是否安装成功

/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.1.55, for unknown-linux-gnu (x86_64) using EditLine wrapper

[root@pgb203 mysql]#/etc/init.d/mysql.server status

MySQL is not running [失败]
//查看mysql运行状态

[root@pgb203 mysql]#/etc/init.d/mysql.server start

Starting MySQL. [确定] //启动mysql

([root@pgb203
mysql]#/etc/init.d/mysql.server stop //停止mysql)

[root@pgb203 mysql]#/etc/init.d/mysql.server status

MySQL running (21711)[确定] // 查看mysql运行状态

[root@pgb203 mysql]# /usr/local/mysql/bin/mysql //登录mysql

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

Your MySQL connection id is 7

Server version: 5.1.55-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit //退出mysql登录状态

Bye

[root@pgb203 mysql]# //到此处mysql已安装成功

我们可以用mysql客户端(windows)SQLyogEnt远程登录linux下mysql数据库,还需要开放权限,具体如下:

[root@pgb203 mysql]# /usr/local/mysql/bin/mysql

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

Your MySQL connection id is 7

Server version: 5.1.55-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
//登录mysql

mysql>GRANT ALL PRIVILEGES ON *.* TO
'myuser'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.0.203' IDENTIFIED BY '123456' WITH GRANT OPTION;

mysql>GRANT ALL PRIVILEGES ON *.* TO 'gsms'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'gsms'@'192.168.0.203' IDENTIFIED BY '123456' WITH GRANT OPTION;

执行后提示如下:



[root@pgb203
mysql]#/etc/init.d/mysql.server stop

[root@pgb203 mysql]#/etc/init.d/mysql.server start
//重启mysql,就可以在windows远程操作数据库了

错误描述:
Mysql中添加用户之后可能出现登录时提示ERROR 1045 (28000): Access denied for user的错误

#
/etc/init.d/mysql stop

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

# mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;

mysql> FLUSH PRIVILEGES;

mysql> quit

# /etc/init.d/mysql restart

# mysql -uroot -p

Enter password: <输入新设的密码newpassword>

mysql>

数据库的备份与还原:

[root@pgb203 ~]# /usr/bin/mysqldump -h127.0.0.1 -uroot -p123456 list >/home/liruixuan/backlist.sql

[root@pgb203 ~]# /usr/bin/mysql -h127.0.0.1 -uroot -p123456 list0613 </home/liruixuan/backlist.sql

安装中出现如下问题:checking for termcap functions library... configure: error: No curses/termcap library found。

解决方法:http://blog.csdn.net/zccst/article/details/4493074

已经不记得这次是第几次安装mysql了,遇到这个问题倒是第一次。

之前在tar,./configure,make,make install 经典四步时,从来没有想过其中的过程,只觉得像例行公事一样,做就是了。

不幸的是,这次在./configure后,make时出现以下错误:

make: *** No targets specified and no makefile found. stop.

本来这次还是想向别人请教的,后来转念一想,前段时间还告诉自己:遇到问题,首先想到自己解决。

于是,在网上找到相关资料,确认是./configure出了问题,于是回头查看,果然发现问题:

最后几行出了错。完整错误信息如下:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for tgetent in -ltinfo... no

checking for termcap functions library... configure: error: No curses/termcap library found

原因:

缺少ncurses安装包

解决办法:

下载安装相应软件包

一、如果你的系统是RedHat系列:

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

二、如果你的系统是Ubuntu或Debian:

apt-cache search ncurses

apt-get install libncurses5-dev

待安装completed!之后,再./configure,顺利通过,然后make && make install,成功安装,一切OK!~~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: