Mysql> alter table change varchar (50) Make a unique column so you get no dupes. Mysql> alter table add column varchar (20) Change column name. Mysql> alter table drop column Add a new column to db. Mysql> DELETE from where = ‘whatever’ Update database permissions/privilages. Mysql> UPDATE SET Select_priv = ‘Y’,Insert_priv = ‘Y’,Update_priv = ‘Y’ where = ‘user’ Delete a row(s) from a table. Mysql> grant all privileges on databasename.* to flush privileges To update info already in a table. Mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES (‘%’,’databasename’,’username’,’Y’,’Y’,’Y’,’Y’,’Y’,’N’) Mysql> flush privileges Give user privilages for a db. Mysql> grant usage on *.* to identified by ‘passwd’ # mysqladmin -u root -p oldpassword newpassword Allow the user “bob” to connect to the server from localhost using the password “passwd”. # mysqladmin -u root password newpassword Update a root password. # /etc/init.d/mysql start Set a root password if there is on root password. Mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’ Mysql> flush privileges Recover a MySQL root password. Mysql> SET PASSWORD FOR = PASSWORD(‘passwordhere’) # /bin/mysqladmin -u username -h -p password ‘new-password’ Change a users password from MySQL prompt. Mysql> flush privileges Change a users password from unix shell. Mysql> INSERT INTO user (Host,User,Password) VALUES(‘%’,’username’,PASSWORD(‘password’)) Mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id Creating a new user. Mysql> SELECT SUM(*) FROM Join tables on common columns. Mysql> SELECT, FROM ORDER BY DESC Return number of rows. Mysql> SELECT DISTINCT FROM Show selected records sorted in an ascending (asc) or descending (desc). Mysql> SELECT * FROM WHERE rec RLIKE “^a” Show unique records. Use “REGEXP BINARY” to force case-sensitivity. Mysql> SELECT * FROM WHERE name like “Bob%” AND phone_number = ‘3444444’ limit 1,5 Use a regular expression to find records. Mysql> SELECT * FROM WHERE name like “Bob%” AND phone_number = ‘3444444’ Show all records starting with the letters ‘bob’ AND the phone number ‘3444444’ limit to records 1 through 5. Mysql> SELECT * FROM WHERE name != “Bob” AND phone_number = ‘3444444’ order by phone_number Show all records starting with the letters ‘bob’ AND the phone number ‘3444444’. Mysql> SELECT * FROM WHERE name = “Bob” AND phone_number = ‘3444444’ Show all records not containing the name “Bob” AND the phone number ‘3444444’ order by the phone_number field. Mysql> SELECT * FROM WHERE = “whatever” Show all records containing the name “Bob” AND the phone number ‘3444444’. Mysql> show columns from Show certain selected rows with the value “whatever”. Mysql> SELECT * FROM Returns the columns and column information pertaining to the designated table. Mysql> drop table Show all data in a table. Mysql> show tables To see database’s field formats. Mysql> use To see all the tables in the db. Mysql> show databases Switch to a database. Mysql> create database List all databases on the sql server. # /bin/mysql -h hostname -u root -p Create a database on the sql server. To login (from unix shell) use -h only if needed.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |