Common connection function mysql_connect ()
Mysql_connect (Servername,username,password);
Long connection function Mysql_pconnect ()
Mysql_pconnect (Servername,username,password);
The code is as follows
Copy Code
$con
Its MySQL default character set turns out to be Swedish (LATIN1_SWEDISH_CI). Manually one table to modify the character set to Unicode multiple languages (UTF8_UNICODE_CI).
Had to check the data, found a solution, that is, after mysql_connect add a
The code is as follows
Copy Code
function replace () {$sql = Db_query ("Select Field_languages_value,nid from {content_type_company_profile} WHERE"Field_languages_value like '%mandarin chinese% ' ");while ($result = Db_fetch_object ($
Novice initial examination, but also please the road Master a lot of guidance.
The program source code is as follows:
$conn = mysql_connect ("localhost", "root", "") or Die ("wrong!");$sel =mysql_select_db ("MyDB", $conn);$sql = "INSERT into '
Length: is a calculation of the lengths of a field a Chinese character is counted three characters, a number or letter is counted as a character
Char_length: Whether Chinese characters or numbers or letters is a character
Example:
1, you want to
Use \ \ or see how you define the string. In fact, there are only two escapes: PHP and MySQL.
In PHP, if you define a string with double quotes, there is an escape here. If you use single quotes, you do not escape.$sql = "SELECT * FROM table WHERE
Commonly used statements
1, look for redundant records in the table, duplicate records are based on a single field (MAIL_ID) to judge
The code is as follows
Copy Code
SELECT * FROM Table WHERE mail_id to (select mail_id
MySQL command mode is connected to MySQL as follows
The code is as follows
Copy Code
Mysql-h host Address-u user name-P user Password
1, connected to the MySQL on the computer.
First open the DOS window, then
Forgot the MySQL root password, you can reset it in the following ways:
1. Kill off the MySQL process in the system;
The code is as follows
Copy Code
Killall-term mysqld
2. Use the following command to start
Method One:
(for administrators or users with global permissions to reset another user's password)Enter command line modeMysql-u Root MySQLmysql> UPDATE user SET Password=password ("New password") WHERE user= ' name ';mysql> FLUSH privileges;Mysql>
Dbhost to your database server address (small tip: General host default database server address is: localhost)Dbuser change to your database user namePassword change to your database user passworddbname change to your database nameBackup.sql
It is often found that developers look up the statements that are not indexed or limit N, these no statements will have a significant impact on the database, such as a large table of tens of millions of records to scan all, or do not stop doing
Take a practical example to understand the associated subquery
Left join: A left-hand connection that returns all the records in the left table and the records in the right table that are equal to the join field.Right join: A right-hand join that
Backup and Recovery
For example, we want to back up the MySQL already exists in the database named Linux, to use the command mysqldump
The command format is as follows:
[Root@linuxsir01 root]# mysqldump-u root-p linux >/root/linux.sqlEnter
First step: Define your backup directory on your Linux server:
The code is as follows
Copy Code
Mkdir/var/lib/mysqlbackupCd/var/lib/mysqlbackup
The second step: The following is the most important step, is to
I. 10 sentences1. do not rely ON the register_global = ON environment, from the day when you just learned how to configure the php runtime environment and even do not understand the impact of register_global ON/off on yourself, we should be brave
Now we have a program code that allows users to input a joke and add it to our database. The rest is to add it to the joke display page we have prepared. Because the vast majority of users only want to watch jokes, we do not want to make major
SQL in MySQLFor MySQL, the first thing you must remember is that every line of its command is ended with a semicolon (;), ...... There is no such thing as absolute. The same is true here.As I mentioned earlier, when a MySQL line is inserted into the
Class mySqlClass {// define the entire database metadata class mySqlClassVar $ querynum = 0; // variable of the number of queries // Open the connection to the server -----------------------------------------------------------------------------------
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