Difference between revisions of "MySQL"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(→‎Articles: link to backing-up article)
(→‎Working Notes: autonumbering; cleaned up section)
Line 10: Line 10:
  
 
==Working Notes==
 
==Working Notes==
* If mysql refuses to respond to connection attempts from anywhere but the local machine, you need to edit /etc/mysql/my.conf and comment out the following line:
+
===external connections===
 +
If mysql refuses to respond to connection attempts from anywhere but the local machine, you need to edit /etc/mysql/my.conf and comment out the following line:
 
  bind-address  = 127.0.0.1
 
  bind-address  = 127.0.0.1
 
: and then restart mysqld.
 
: and then restart mysqld.
* To restart the mysql [[daemon]] (mysqld) when you don't have a user with SHUTDOWN privileges but you do have system root:
+
===miscellaneous===
 +
To restart the mysql [[daemon]] (mysqld) when you don't have a user with SHUTDOWN privileges but you do have system root:
 
  sudo /etc/init.d/mysql restart
 
  sudo /etc/init.d/mysql restart
* To work around the Query Browser bug which won't let you edit a blank table, create the first entry using MySQL's command line interface:
+
===Query Browser bugs===
 +
On [[Ubuntu]] 6.06 and earlier (I don't know if this has been fixed yet), the [[MySQL Query Browser]] has a tendency to crash when editing tables (this happens, unfortunately, before it even displays the required SQL, so you can't use it to work that out for you). This problem does not seem to affect the SQL window, so you can make the needed changes using SQL either in that window or via the [[CLI]] client – but working out the exact syntax can be tricky.
  
  woozle@camilla:~ $ mysql -h''yourhost'' -u''yourusername'' -p''yourpassword''
+
'''editing a blank table''': To work around the Query Browser bug which won't let you edit a blank table, create the first entry using MySQL's command line interface:
 +
 
 +
  woozle@camilla:~ $ mysql -h<u>yourhost</u> -u<u>yourusername</u> -p<u>yourpassword</u>
 
  Welcome to the MySQL monitor.  Commands end with ; or \g.
 
  Welcome to the MySQL monitor.  Commands end with ; or \g.
 
  Your MySQL connection id is 12531702 to server version: 4.1.13-standard
 
  Your MySQL connection id is 12531702 to server version: 4.1.13-standard
Line 23: Line 28:
 
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
   
 
   
  mysql> use ''yourdatabasename''
+
  mysql> use <u>yourdatabasename</u>
 
  Reading table information for completion of table and column names
 
  Reading table information for completion of table and column names
 
  You can turn off this feature to get a quicker startup with -A
 
  You can turn off this feature to get a quicker startup with -A
Line 33: Line 38:
 
  mysql>
 
  mysql>
  
...where ''yourhost'' is the name of your MySQL server, and can be anything that can resolve to an IP address, e.g. localhost, yourmachinename, yourserverdomain.com, or an actual IP address (I think).
+
...where <u>yourhost</u> is the name of your MySQL server, and can be anything that can resolve to an IP address, e.g. localhost, yourmachinename, yourserverdomain.com, or an actual IP address (I think).
* If the Query Browser crashes when you try to create or edit a table, use the command line interface to create the table:
+
 
 +
'''creating a table''': If the Query Browser crashes when you try to create or edit a table, use the command line interface to create the table:
 
  create table <u>table_name</u> (<u>field_name</u> <u>field_type</u>, <u>field_name</u> <u>field_type</u>{{optargs|, ...}});
 
  create table <u>table_name</u> (<u>field_name</u> <u>field_type</u>, <u>field_name</u> <u>field_type</u>{{optargs|, ...}});
 
Example:
 
Example:
 
  create table example (key varchar(255));
 
  create table example (key varchar(255));
 +
 +
'''making a field autonumbered''': Use the following SQL:
 +
'''ALTER TABLE''' <u>tablename</u> '''MODIFY''' <u>fieldname</u> <u>fieldtype</u> '''AUTO_INCREMENT''';
 +
Example:
 +
'''ALTER TABLE''' Tracks_Queued '''MODIFY''' id '''INTEGER AUTO_INCREMENT''';
  
 
==Links==
 
==Links==

Revision as of 14:22, 19 November 2006

computing: software: MySQL

This page is a seed article. You can help HTYP water it: make a request to expand a given page and/or donate to help give us more writing-hours!

MySQL is a FOSS database engine and server. It fills roughly the same niche as Microsoft SQL Server.

The MySQL package (at least in Linux) comes with a number of helper utilities, including MySQL Administrator and MySQL Query Browser. The Administrator utility is useful for making backups, and the Query Browser serves as a front-end for interacting with databases. The Query Browser is, however, somewhat buggy as of version 4.

Articles

Criticisms

MySQL has been criticized by at least one user of lacking production-quality features, with version 5.0 only just starting to add them, where as other FOSS alternatives such as PostgreSQL had such features in their very earliest versions. MySQL has also been criticized for bad performance, e.g. locking entire tables when it only should have locked a row, as well as general incompatibility (Editor's note: with what?). (See also Wikipedia:MySQL#Criticisms of MySQL)

Working Notes

external connections

If mysql refuses to respond to connection attempts from anywhere but the local machine, you need to edit /etc/mysql/my.conf and comment out the following line:

bind-address  = 127.0.0.1
and then restart mysqld.

miscellaneous

To restart the mysql daemon (mysqld) when you don't have a user with SHUTDOWN privileges but you do have system root:

sudo /etc/init.d/mysql restart

Query Browser bugs

On Ubuntu 6.06 and earlier (I don't know if this has been fixed yet), the MySQL Query Browser has a tendency to crash when editing tables (this happens, unfortunately, before it even displays the required SQL, so you can't use it to work that out for you). This problem does not seem to affect the SQL window, so you can make the needed changes using SQL either in that window or via the CLI client – but working out the exact syntax can be tricky.

editing a blank table: To work around the Query Browser bug which won't let you edit a blank table, create the first entry using MySQL's command line interface:

woozle@camilla:~ $ mysql -hyourhost -uyourusername -pyourpassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12531702 to server version: 4.1.13-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use yourdatabasename
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> INSERT INTO tablename () VALUES();
Query OK, 1 row affected (0.05 sec)

mysql>

...where yourhost is the name of your MySQL server, and can be anything that can resolve to an IP address, e.g. localhost, yourmachinename, yourserverdomain.com, or an actual IP address (I think).

creating a table: If the Query Browser crashes when you try to create or edit a table, use the command line interface to create the table:

create table table_name (field_name field_type, field_name field_type
  1. REDIRECT Template:arg/opt);

Example:

create table example (key varchar(255));

making a field autonumbered: Use the following SQL:

ALTER TABLE tablename MODIFY fieldname fieldtype AUTO_INCREMENT;

Example:

ALTER TABLE Tracks_Queued MODIFY id INTEGER AUTO_INCREMENT;

Links