Windows System configuration MySQL
Unable to connect to MySQL, wrote a test MySQL PHP file as follows:
The code is as follows |
Copy Code |
<?php$link=mysql_connect (' localhost ', ' root ', ' root '); if (! $link) echo "Failed!"; Else echo "Success!" Mysql_close (); ?> |
Results reported errors: Fatal error:call to undefined function mysql_connect (), obviously unable to find the corresponding library of MySQL, Baidu a lot of, is what copy MySQL Lib library, is also copied to Windows System32 directory, too complex, in fact, the correct configuration should be in the Apache httpd.conf file to add the settings:
The code is as follows |
Copy Code |
LoadModule Php5_module D:/tools/php-5.3.1/php5apache2_2.dll AddType application/x-httpd-php. php Phpinidir d:/tools/php-5.3.1 |
Note that the last line is the key, tell Apache where your PHP configuration file is, or you'll have to copy the php.ini file to the Windows system directory. In general, we can complete the combination of Apache and PHP through this configuration. And in the php.ini file only need to modify the following several places to:
# Modify PHP's extension library directory for your actual path
Extension_dir = "D:/tools/php-5.3.1/ext" # Remove the front; extension=php_mysql.dll
configuring MySQL in Linux
First download MySQL's DMG installation package. Download address in: http://dev.mysql.com/downloads/mysql/
Open the DMG file, which has three installation items, I have three installed, Mysqlstartupitem.pkg installed, MySQL will start with the system boot, Mysql.prefpane said you can see the system Preferences in the MySQL option, there is a MySQL installation.
This makes the installation successful, opens MySQL in System Preferences, and opens the service. When installed, the default username is root and the password is blank. For security, we set a password.
Open the terminal, if you enter the MySQL hint without this command, then need to configure the MySQL Bin directory environment variables. The directory is,/usr/local/mysql/bin/, added to the path variable. Here I introduce another method,
Enter in the terminal
The code is as follows |
Copy Code |
sudo vim/etc/bashrc |
And then join the
The code is as follows |
Copy Code |
#mysql Alias mysql= '/usr/local/mysql/bin/mysql ' Alias mysqladmin= '/usr/local/mysql/bin/mysqladmin ' |
As a result, enter MySQL in the terminal has this command, in fact, it and our C/s + + macro definition somewhat similar to the role of alias substitution.
We then modify the root password, which commands the following:
The code is as follows |
Copy Code |
Mysqladmin-uroot Password 12345
|
This will change the root password to 12345.