[Openwrt Project Development Note]:mysql configuration (vi)

Source: Internet
Author: User
Tags mysql in

In my project, the server running on the router uses the nginx+mysql+php architecture. Often the more common web framework is lamp (linux+apache+mysql+php), why do we choose LNMP? I will give the answer in a few subsequent articles.

First, we'll show you how to build a MySQL database on OpenWrt.

Reference article: (http://blog.csdn.net/yufei_email/article/details/21845935)

First, install the MySQL database (in the backfire10.3 version, the package already contains MYSQL-SERVER.IPK) so it can be installed directly through OPKG.

opkg updateopkg install MySQL-server

Second, set up the MySQL configuration file (/etc/my.cnf)

1. Modify the location of the database (find the following configuration in/etc/my.cnf)

DataDir            =/mnt/data/mysqltmpdir             =/mnt/data/tmp

Change to:

DataDir             =/mnt/sda3/data/mysql     #将数据库放置到U盘对应分区上存储tmpdir              =/mnt/sda3/data/tmp       #将数据库临时文件夹存放到U盘对应分区上 #本人的数据库存放在U盘第三个分区上, i.e.  /mnt/sda3, you have to modify it according to your needs.

2. Modify the binding address of the database (find the Bind-address property)

bind-address        =127.0.  0.1

Change to:

bind-address        =0.0.  0.0

Purpose of modification: allow remote access.

Save the changes and exit the edit.

3. Create a Database Storage folder (do this if the DataDir in my.cnf and the tmpdir corresponding storage location do not exist, otherwise skip this step)

mkdir/mnt/sda3//mnt/sda3/data//mnt/sda3/data/tmp-p/mnt/sda3/data/mnt/ Sda3/data/mysql/mnt/sda3/data/tmp

4. Create DATABASE (perform the following actions)

/usr/bin/mysql_install_db--force

Third, start the MySQL database

1. Start the MySQL daemon

/etc/init.d/mysqld enable/etc/init.d/mysqld start

2. Start the MySQL server interaction process:

The parents who have used MySQL know that the operation of the MySQL database needs to be done by the corresponding user. No password has been set for the user in the database that has just been built. So how do you set it up? There are two ways to do this:

Method One:

Use the Mysqladmin command to pre-set the corresponding user MySQL password, as a root user example:

/usr/bin/mysqladmin-u root password XXXXXX   #  XXXXXX is the password set for the root user

Method Two:

Enter MySQL in an unauthorized way to set permissions:

#start mysqld in a non-authoritative manner. Mysqld--skip-grant&#root User login MySQLMySQL-u root#To see if a MySQL database existsshow databases; Usemysql;update user Set Password=password ('XXXXXX') Where user='Root'and host='localhost'; flush privileges;Exit

Tips: In this modification, we only set the username and password of localhost, and no other permissions are set. If necessary, set it up separately.

Close Mysqld Service

Killall mysqld

Restart MYSQLD Service

/etc/init.d/mysqld start

After setting the password and permissions, log in to MySQL as the root user:

Mysql-u root-p

OK to this MySQL will be able to log in and use the normal.

Iv. problems encountered and solutions

When I install the startup MySQL, the system error:

Can'libncurses.so. 5 ' ...

On the Internet to view a variety of posts, found that everyone said is good tall, what kernel version is wrong, what file link error. After several changes, or did not solve the problem, and then inadvertently to find, incredibly found the Libncurses installation package ...

http://downloads.openwrt.org/backfire/10.03/ar71xx/packages/

The solution to the original library file that lacks libncurses is:

Opkg Install Libncurses

After installation, restart the MySQL service to log in normally.

The next section describes installing Php+mysql on OpenWrt.

Reprint please indicate source: http://www.cnblogs.com/double-win/Thank you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.