Terms of Service Privacy Policy Contact Us

leistware.com

MySQL

MySQL Resource Center


MySQL is one of my favorite databases to work with. It has it's limitations but overall it is a pretty well rounded system for the money. I particularly like to code stored procedures in MySQL. It is more like a program that a stored proc.

CREATED 2012-08-22 10:13:42.0

00-16-41

UPDATED 2012-11-14 16:04:16.0

Starting an Stopping...


To start, stop and restart MySQL on Linux use these commands

/etc/init.d/mysql start /etc/init.d/mysql stop /etc/init.d/mysql restart


...Windows is different. There are two seperate files to use. mysqld and mysqladmin. To start use:

patsh_to_mysql]/bin/mysqld i.e. C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqld


...to stop use:

[path_to_mysql]/bin/mysqladmin shutdown i.e. C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqladmin shutdown


CREATED 2012-11-19 05:48:34.0

00-17-EC

UPDATED 2012-11-19 05:48:49.0

MySQL Port


To find out what port MySQL is running on, from the server use this:

netstat -an | grep -i mysql

Or look in the /etc/mysql/my.cnf for this section...

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

CREATED 2012-11-23 15:22:44.0

00-18-30

UPDATED 2012-11-23 15:22:50.0

Connecting... or not?


To connect to MySQL... not that hard...

mysql -u [username] -p

Better not to add the password here. Let MySQL Prompt for it. If it is added on the command line it's not encrypted. If MySQL prompts for it, it is.

Can't connect remotely? Check the config file in /etc/mysql/my.cnf. Look for the BIND_ADDRESS, if it is 127.0.0.1 -> change it to the machine address.

CREATED 2012-11-21 22:23:13.0

00-18-20

UPDATED 2012-11-21 22:23:24.0

Connecting to a Remote...


Connecting to a remote server with MySQL...

mysql --h [host | IP] -u [username] --password=[passowrd] [database]
   OR
mysql --host=[host | IP] --user=[username] --password=[passowrd] [database]

Example:

mysql --host=24.10.2.101 --user=kennyl --password=apassword BW
   OR
mysql --host=savage --user=kennyl --password=apassword BW
   OR
mysql -host savage -u kennyl -p

It is best to just use -p with no password. MySQL will prompt you for the password and encrypt it as it is typed. If a password must be used, there should be no space between --password= and the actual password.

Note: when creating passwords they are actually logged in a file called .mysql_history in the home directory. It is a good idea to keep track of this file. I delete the file on logout. in plain test

CREATED 2012-11-19 06:14:31.0

00-17-ED

UPDATED 2012-11-19 06:14:40.0

Knowledge

String Functions
Date Time Functions

Page Server: Ithica

DBID: db.wam

©2012 Leistware Data Systems

      Hello anonymous