Archlinux安装MySQL的正确方法,解决root密码错误问题
网上的资料竟然没有一个是对的,包括arch linux官方给的都不对, 更要命的是安装mysql时系统给的提示都不对。我google了关于中文arch linux安装mysql的问档,最新的也是去年的。 可今年都过了一半了。 于是我又不得不搜索了英文网站。总算找到一个还算行的通的方法,但是这个老外给的也不完全对,有一个步骤没给导致了mysql不能启动。 这里我把正确的方法帖出来。我用的是最新的arch linux2009.02版。
如果你已经安装了mysql,经过多次设置root密码还是失败, 那么你最好还是从头开始,把已经装好的mysql删除。但是如果还没安装的可以直接从第3步开始。 另外,我用的是root帐号, 普通的帐号自己加sudo。
1。#移除已经安装的mysql数据库文件 #rm -r /var/lib/mysql 2。移除mysql #pacman -Rn mysql 3. 安装mysql #pacman -S mysql 4. 初始化数据库 #/usr/bin/mysql_install_db
5. 老外也没给的步骤就是这一步了, 初始化数据库后 /var/lib/mysql是属于root的, mysql没法写,所以改属主
#
chown -R mysql:mysql /var/lib/mysql 6。mysql初始化
#/usr/bin/mysql_secure_installation
完毕后就可以用mysql -u root -p来登录了。 根本不是用什么mysqladmin来初始化密码。 当然这仅仅限于arch linux.
arch linux速度是比ubuntu server快些。因为去掉了很多不必要的东西。 如果自己配制linux内核,应该会有更快的速度。
? su -
? pacman -S mysql mysql-gui-tools
? run mysql_install_db –user=mysql in /var/lib/mysql
? vim /etc/my.cnf, disable skip_networking to allow tcp/ip connection ? vim /etc/hosts.allow, add mysql:all:allow ? /etc/rc.d/mysql start
? mysqladmin -u root password #NEW_PASSWORD# to set root password
Introduction
MySQL is a widely spread, multi-threaded, multi-user SQL database. For more information about features, see theofficial homepage.
Installation
Install the mysql package: # pacman -S mysql
After installing MySQL you should run arch's init script as root: # /etc/rc.d/mysqld start
This will take care of the basic configuration as adding system users and creating log files. This script also prints out how to configure MySQL after the first start.
Configuration
Once you've started the MySQL server, you probably want to add a root account in order to maintain your MySQL users and databases. This can be done manually or automatically, as mentioned by the output of the above script. Either run the commands to set a password for the root account, or run the secure installation script.
You now should be able to do further configuration using your favorite interface. For example you can use MySQL's command line tool to login as root into your MySQL server:
$ mysql -p -u root
To start MySQL at bootup add mysqld
to the list of daemons in /etc/rc.conf or add
/etc/rc.d/mysqld start to /etc/rc.local
.
The MySQL server does not listen on the TCP port 3306 by default. To allow (remote) TCP connections, comment the line containing 'skip-networking' in /etc/my.cnf. Remember to edit /etc/hosts.allow by adding the following line:
mysqld: ALL Troubleshooting
How to Reset the Root Password Stop mysqld daemon
# /etc/rc.d/mysqld stop # mysqld_safe --skip-grant-tables & Connect to mysql server # mysql -u root mysql Change root password:
mysql> UPDATE user SET password=PASSWORD(\User='root'; mysql> FLUSH PRIVILEGES; mysql> exit
Then restart daemon: # /etc/rc.d/mysqld restart You're done
WHERE
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Archlinux安装MySQL的正确方法在线全文阅读。
相关推荐: