Exporting & Importing individual MySQL table command line

[dfads params=’groups=-1′]

Exporting Table

The following command syntax will export individual MySQL table from the Database:

$ mysqldump -u root -p db_name tbl_name > sql_script.sql


Importing Table

The follwoing command syntax will import individual MySQL table to the Database:

$ mysql -u root -p db_name < sql_script.sql


Both of the above command will prompt password for the root user.

[dfads params=’groups=-1′]

How to update mysql root password in mysql?

[dfads params=’groups=-1′]


The Following five steps will help you to update your mysql root password in mysql:

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for a password.

Step # 3: Connect to the MySQL server as the root user.

Step # 4: Set a new root password.

Step # 5: Exit and restart the MySQL server.

Here are the commands you need to type for each step (log in as the root user):

Step # 1 : Stop the MySQL service:

# /etc/init.d/mysql stop


Stopping MySQL database server: mysqld.

Step # 2: Start the MySQL server w/o password:

# mysqld_safe –skip-grant-tables &


[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to the MySQL server using the MySQL client:

# mysql -u root


Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.


Step # 4: Set a new MySQL root user password:

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

Step # 5: Stop the MySQL server:

# /etc/init.d/mysql stop


Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+  Done                    mysqld_safe –skip-grant-tables

Start the MySQL server and test it:

# /etc/init.d/mysql start
# mysql -u root -p


[dfads params=’groups=-1′]

Fix `ereg is deprecated` errors in PHP 5.3


If you upgraded to PHP 5.3, chances are high you’re going to run into a few warnings or deprecated function messages.
An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.

To migrate ereg():

1. ereg(‘.([^.]*$)’, $this->file_src_name, $extension);


1. preg_match(‘/.([^.]*$)/’, $this->file_src_name, $extension);

Notice that I wrapped the pattern (.([^.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.

To migrate ereg_replace():

1. $this->file_dst_name_body = ereg_replace(‘[^A-Za-z0-9_]’, ”, $this->file_dst_name_body);


1. $this->file_dst_name_body = preg_replace(‘/[^A-Za-z0-9_]/’, ”, $this->file_dst_name_body);

Again, I just added delimiters to the pattern.
If you are using eregi functions (which are the case-insensitive version of ereg), you’ll notice there’re no equivalent pregi functions. This is because this functionality is handled by RegExp modifiers.

Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter:

1. eregi(‘.([^.]*$)’, $this->file_src_name, $extension);


1. preg_match(‘/.([^.]*$)/i’, $this->file_src_name, $extension);