亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1531 | 回復(fù): 0
打印 上一主題 下一主題

RHEL install and configure MySQL database [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-12-23 03:03 |只看該作者 |倒序瀏覽

Q. How do I install MySQL database server under Redhat Enterprise Linux 5?

A. You have two choices:

a) Install MySQL package using RHN

b) Install MySQL rpm from CD/DVD

Red hat Enterprise Install Mysql Database server

The best way to install mysql package is to use RHN (Red Hat Network):

Redhat Enterprise Linux - RHEL 5 MySQL installation

Type the following command as root user:
# yum install mysql-server mysql
Note above yum command works with Fedora core and Cent OS Linux.

Redhat Enterprise Linux - RHEL 4/3 MySQL installation

Type the following command as root user:
# up2date mysql-server mysql

Start MySQL Service

To start mysql server type the following command:
# chkconfig mysqld on
# /etc/init.d/mysqld start

Setup mysql root password

Type the following command to setup a password for root user:
# mysqladmin -u root password NEWPASSWORD

Test mysql connectivity

Type the following command to connect to MySQL server:
$ mysql -u root -p







Fix: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

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

if you are new to installing mysql server you might probably face this error quite often if you type mysql in the shell prompt.

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

To fix:

First start the mysql daemon, then type mysql

> /etc/init.d/mysqld start
> mysql

Bingo! It worked for me!

To update mysql root password

mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(‘new-password’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;

To add a new user to mysql

1. First login as root then create a database ‘demo’

> mysql -u root -p
Enter password:
mysql> create database demo;

After that create a new user named ‘guest’ with password ‘guest’ with all previleges assigned to demo database;

mysql> GRANT ALL PRIVILEGES ON mytest.* TO ‘guest’@'localhost’ IDENTIFIED BY ‘guest’ WITH GRANT OPTION;

Then exit mysql and connect through username guest;
That should work!




Correct syntax to start / stop / restart with sudo:
sudo /etc/init.d/mysqld start
sudo /etc/init.d/mysqld status
sudo /etc/init.d/mysqld restart
sudo /etc/init.d/mysqld stop
OR
sudo /sbin/service mysqld start
What is the output of the following command?
netstat -tulnp | grep mysql




啟動mysql時報錯:

Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
071112 00:22:06 mysqld ended

查看日志:

#less /var/log/mysqld.log

其中有一段如下:


071112 0:22:06 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
071112 0:22:06 [ERROR] Can't start server: can't create PID file: No such file or directory
071112 00:22:06 mysqld ended

#cd /var/run/
#ls


mysqld目錄不存在,創(chuàng)建它:


#mkdir /var/run/mysqld
#cd /var/run/mysqld


創(chuàng)建文件mysqld.pid:


#touch mysqld.pid
#cd..
#chown -R mysql mysqld .

#cd /usr/local/mysql/
#bin/mysqld_safe --user=mysql &
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql

能正常啟動

#bin/mysqladmin -u root password root

又出錯

[root@localhost mysql]# bin/mysqladmin -u root password root
bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

[root@localhost mysql]# bin/mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

分析:是/tmp/mysql.sock 不存在


# cd /var/lib/mysql/

由于mysql 默認(rèn)的mysql.sock 是在/var/lib/mysql/mysql.sock,創(chuàng)建符號連接:


# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
# bin/mysql -u root
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.45 MySQL Community Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>




我將s9當(dāng)眾原來的mysql4.0刪除后,重新裝了個mysql5.0,啟動過程中報一下錯誤,啟動失敗,查了一下群里面的老帖子也沒有個具體的明確說明,還請那位高手說明一下怎么解決。謝謝
error 日志當(dāng)中的記錄:

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist



從發(fā)了帖子,只有人看,沒有人回復(fù),看到這種情況只能自己解決問題了,自己動手豐衣足食嗎, 嗯。。。 你還別說,還真讓我解決了問題,人啊,都是逼出來的,....沒有辦法,這個問題對于高手可能是很簡單的問題 ,但是對我第一次摸mysql,確實怎么也弄不懂的問題。
好了閑話不多說 說一下我解決的過程:

按照mysql的安裝步驟:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql-VERSION
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root  /usr/local/mysql
shell> chown -R mysql /usr/local/mysql/var
shell> chgrp -R mysql /usr/local/mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

這樣標(biāo)準(zhǔn)進(jìn)行下來是沒有問題的,但在最后一步啟動mysql的時候我希望將數(shù)據(jù)庫的數(shù)據(jù)文件放在另外一個目錄下面,啟動命令修改為:
shell>/usr/local/mysql/bin/mysqld_safe --user=mysql --log-error=/u01/mysql/mysql_error/error --datadir=/u01/mysql/data

這個時候就出現(xiàn)問題了, 因為在進(jìn)行初始化數(shù)據(jù)庫權(quán)限表的那一步的時候默認(rèn)創(chuàng)建的權(quán)限表在默認(rèn)目錄/usr/local/mysql/var下面,這就造成了,上面的錯誤無法找到 權(quán)限表:Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

解決辦法 在運(yùn)行初始化權(quán)限表的時候使用增加參數(shù)--datadir ,命令格式為:
shell> scripts/mysql_install_db --user=mysql --datadir=/u01/mysql/data
這樣問題就解決了。
這樣問題同樣也會出現(xiàn) 你將自己的數(shù)據(jù)庫的數(shù)據(jù)文件修改為別的目錄的時候,因為你沒有在相應(yīng)的目錄下創(chuàng)建數(shù)據(jù)庫權(quán)限表,解決辦法就是你重新運(yùn)行mysql_install_db 文件,重新生成數(shù)據(jù)庫權(quán)限表,但是相應(yīng)的你也要重新建里用戶,以及設(shè)置權(quán)限; 第二個辦法應(yīng)該將老的權(quán)限表的文件拷貝倒相應(yīng)數(shù)據(jù)庫表對應(yīng)的目錄先即可,但是第二個辦法我沒有用過只是根據(jù)自己的想象猜的。如果有高手請給確認(rèn)一下是否正確



您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP