Mac OS X Leopard: Configure Apache, PHP, SQLite, MySQL, and phpMyAdmin (2)

Source: Internet
Author: User
Tags mysql gui
The previous Mac OS X Leopard: configuration of Apache, PHP, SQLite, MySQL, and phpMyAdmin (1) describes the Apache and PHP settings built in leopard, here we will introduce the installation and configuration of MySQL and phpMyAdmin, because these are not the leopard built-in software (the leopard server has built-in MySQL), so there will be some problems, here I will provide a solution to the main problems.

Iii. MySQL
If you are running the OS x Leopard server, MySQL is installed by default in the system. Otherwise, you need to install MySQL on the OS X Leopard client. you can refer to the official installation instructions of MySQL. however, my solution to the problem is not found in the description.

1. Download the package: The current version is 5.1. Its download URL is MySQL 5.1, which is under the Mac OS x Project. Currently, it includes OS X 10.4 (PPC, x86 ), OS x 10.5 (PPC, x86) Public 7 versions, find your own version, I choose Mac OS X 10.5 (x86), file name is mysql-5.1.30-osx10.5-x86.dmg. the package size is more than 60 MB. It takes about MB to decompress the package.

2. Install the packageThe downloaded DMG file contains two installation packages, one is the MySQL package (mysql-version-osx10.5-x86.pkg), the other is the package that runs MySQL automatically at startup (mysqlstartupitem. PKG ). first, install the package. The installation path is/usr/local/MySQL-version, and a symbolic link is generated in the/usr/local/MySQL directory ), if the directory already exists, it first moves the original directory to/usr/local/MySQL. bak.

MySQL installation requires a MySQL user in the system. This user is one of the default users of OS X, and the username in leopard is _ MySQL. if the user is lost for any reason, generate the user by yourself.

3. Install the Automatic startup package again.
After installation, you can see the following file:

Next, let's roughly analyze what startupitem. PKG has done. We can check its postinstall script file.
First, it deletes the possible MySQL settings in the original hostconfig file,

  1. Sed-e s/^ MySQL =-yes-/MySQL =-no-/g </etc/hostconfig>/temp/hostconfig

Then add mysqlcom =-yes-to the temporary file/temp/hostconfig.

  1. Echo "mysqlcom =-yes-">/temp/hostconfig

Finally, move the temporary file to/etc/and modify the file attributes:

  1. MV-F/temp/hostconfig/etc/hostconfig
  2. Chmod 644/etc/hostconfig

4.In fact, there is anotherSystem Preference plugin, Which is not mentioned in the description. you can install it if you like:
This file is mysql. prepane. You only need to drag it to the/library/preferencepanes directory and open system preferences.

5. Environment Settings:
 
This step is optional to facilitate future shell operation management. add the following alias to your shell. My name is Bash, so edit the/etc/bashrc file and add the following two lines:

  1. Alias MySQL '/usr/local/MySQL/bin/mysql'
  2. Alias mysqladmin '/usr/local/MySQL/bin/mysqladmin'

6. Configure MYSQL:
After installation, the most important task is configuration. MySQL configuration is mainly for security settings. For more information about security, see the official documentation:
2.10.3. Securing the initial MySQL accounts

A. Set the root password of the MySQL System Database:
Because the Default Root Password in MySQL is blank, you must reset it to your own password. Remember, if you forget, refer to MySQL Official Document section B .1.4.1, "How to reset the root password" or refer to another article: mysql: reset lost Root Password
You can use the following command to set the root password:

  1. Mysqladmin-u Root Password "mysqlpassword"

"Mysqlpassword" is the password.
Or interactive:

  1. Shell> mysql-u Root

Then set the password:

  1. Mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpwd ');
  2. Mysql> set password for 'root' @ 'host _ name' = PASSWORD ('newpwd ');
  3. Mysql> set password for 'root' @ '127. 0.0.1 '= PASSWORD ('newpwd ');

The host_name is the host name of the MySQL server, and newpwd is your new password.
Or use update to set the password:

  1. Mysql> Update mysql. User SET Password = PASSWORD ('newpwd') where user = 'root ';
  2. Mysql> flush privileges;

B. Note 1:
If the password is set for the first time, run the following command:
Shell> mysql-u Root
To reset the password, add the-P option and enter the current password when it asks for the password:
Shell> mysql-u root-P
The mysqladmin command is also applicable.

C. Anonymous Account:
After installation, the system will also create an anonymous account. You can set a password for it or delete this account:

  1. Shell> mysql-u Root
  2. Mysql> set password for ''@ 'localhost' = PASSWORD ('newpwd ');
  3. Mysql> set password for ''@ 'host _ name' = PASSWORD ('newpwd ');

DELETE command:

  1. Mysql> drop user '';

The following command deletes the anonymous user with the same permissions as root by default:

  1. Mysql> drop user ''@ 'localhost ';

D. Check the user information:

  1. Mysql> select host, user from mysql. user;

For more detailed operations after installation, see MySQL official documentation: 2.10.2. UNIX post-installation procedures

E. Start MYSQL:
Currently, I know three methods:
A. If you have installed startupintems, You can use the following command:

  1. Shell> sudo/library/startupitems/mysqlcom start

B. Common Unix Commands:

  1. Shell> Cd/usr/local/MySQL
  2. Shell> sudo./bin/mysqld_safe

If required, enter the password, Press Control-Z, and then enter the following command to exit terminal.

  1. Shell> BG

C. Gui:
Go to MySQL of system prefeences and have a button to start/stop MySQL.

7. Problem Solving:
A. mysqlcom start cannot start MYSQL:
If mysqlcom is set to =-no-in the hostconfig file, use the following command:

  1. Sudo/library/startupitems/mysqlcom restart

B. If the following error message is displayed: checking the log files, I found that there were incorrect permissions on some of the files. The following steps (from the install_binary Readme) fixed the problem:
Check the permissions of the data directory and modify the following:

  1. % Cd/usr/local/MySQL
  2. % Sudo chown-R _ Mysql Data

C. Unable to start MySql in Gui mode:
One possible problem is that the default socket file of MySQL is modified, while the GUI tool in System Preferences pane uses the default/tmp/MySQL. sock. check/etc/My. CNF file, which can modify the socket location.

8. MySQL GUI Management Program:
MySQL has an official GUI management program called MySQL tools. Go to http://dev.mysql.com/downloads/gui-tools/5.0.htmlto download the introduction to MySQL. The OS X package contains three applications. The MySQL administrator. app is more practical.

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.