[NTLUG:Discuss] MySQL question

rob apodaca robert.apodaca at attbi.com
Thu Jul 25 12:53:46 CDT 2002


On Thu, 25 Jul 2002 14:34:17 -0500
Bobby Wrenn <bjwrenn at augustmail.com> wrote:

> I've checked the MySQL web site, the man pages, the OReilly book and another 
> MySQL book. No help
> 
> I have a default install of MySQL on Mandrake 8.2.
> I type "mysqladmin -u <username>" I get the help screen and the command 
> prompt back. I type "mysql -u <username>" I get the mysql prompt and no 
> password prompt.
> 
> In mysql I type;
> mysql>  create database atestdatabase;
> 
> The system responds;
> ERROR 1044: Access denied for user: '@localhost' to database 'atestdatabase'
> 
> How can I enable access for a user?
> 
> I have only one user on the system. Root cannot even run the mysql CLI.
> What gives?

When mysql checks a user for access, it is checking against it's own built in database called 'mysql'. It has no knowledge of system users. By default, mysql is open to a mysql user called 'root' with a null password. The first thing to do is to secure that by assigning a password for mysql user 'root'. This is only necessary if the machine is part of a network.

Here are a few commands to get you going after you are logged in:
create databasename; #create a database

use databasename; #Use the specified db

create table tablename (id INT NOT NULL AUTO_INCREMENT,stuff VARCHAR(20), morestuff VARCHAR(10), date DATE, PRIMARY KEY ($id) ); #create a table with some fields

INSERT INTO tablename VALUES('', 'blah', 'blah', '2002-07-24'); #insert a record

select * from tablename; #issue a select statement

UPDATE tablename SET (date = '2002-07-25') WHERE id = 1; #change some data

If you are very new to mysql, you might want to try using webmin's mysql module:
https://localhost:10000/mysql/

Of course, IMHO, its better to learn mysql CLI.




More information about the Discuss mailing list