redhat安装mysql

mysql-5.1.57.tar.gz包放在/usr/local/src

cd  /usr/local/src

tar -zxvf  mysql-5.1.57.tar.gz    (-C /usr/xx/  解压到其他目录)

cd mysql-5.1.57

./configure –prefix=/usr/local/mysql

make

make install

不要急着执行红色部分

 

为mysql单独建立一个用户

groupadd mysql
useradd mysql -g mysql

cp /usr/local/src/mysql-5.1.57/support-files/my-small.cnf      /etc/my.cnf    (还有my-medium.conf 、my-large.conf、my-huge.conf)

没有my.cnf报错,大概是cant’write xx.frm (跟目录的权限可能也有关系)

复制之后还是会报错:

Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root!

修改/etc/my.cnf  添加一行  user=mysql

cd /usr/local/mysql/bin

./mysql_install_db –user=mysql (要先执行以上几步骤) (当前路径下的shell脚本运行需要用带上 ./)

输出:

Installing MySQL system tables…
110904  5:57:47 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK
Filling help tables…
110904  5:57:47 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
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 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!

安装系统数据库 mysql和test

警告:–skip-locking过时了,将在未来的版本中被移除,请改用–skip-external-locking  不影响建立系统数据库 只是提示。

可以修改my.cnf  查找–skip-locking 替换为–skip-external-locking  重新./mysql_install_db –user=mysql可以看看就没有提示了  (这个文件log-bin log-format默认开着,也先关了,免得产生日志,做主从复制的时候再开启)

上面告诉你如何方便的启动mysql 并且提醒密码

已经告诉了方法。

 ./mysqld_safe –user=mysql &  (带&表示后台模式 否则当前窗口卡住)

./mysql -u root -p     //目前还没有密码 直接就进去了

show databases;

修改密码

/usr/local/mysql/bin/mysqladmin -uroot password 123

或者应该可以

use mysql;

update mysql set password=password(’123′) where user=’root’;

flush privileges;

 

//添加服务

cp /usr/local/src/mysql-5.1.57/support-files/mysql.server       /etc/init.d/mysqld
cd /etc/init.d/
chmod +x mysqld //添加可执行权限

//添加自启动   http://baike.baidu.com/view/2098380.htm

chkconfig mysqld

chkconfig –add mysqld

chkconfig –level 345 mysqld on
service mysqld restart

 

想在任何路径输入mysql -u root -p 都有效

把 /usr/local/mysql/bin 加到$PATH 变量里:export $PATH.=/usr/local/mysql/bin;

或者给/usr/local/mysql/bin 建立一个软链接到已经在环境变量的路径里:ln -s from  to

ln -s /usr/local/mysql/bin  /usr/bin   (/usr/bin 一般都在环境变量里。可以用echo $PATH;查看)

 

ldconfig相关:http://www.cnblogs.com/arci/archive/2011/03/19/1988952.html

此条目发表在 Linux 分类目录,贴了 , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>