MySQL says table is there, then says it's not - mysql

check the database-generating sql (looks fine):
CREATE TABLE `HourOfDay` (
`id` int(11) NOT NULL,
`hourString` varchar(2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
check the file system (it's there):
# ls -al Mycomp_test | grep -i hour
-rw-rw---- 1 _mysql wheel 0 Mar 1 08:13 HourOfDay.MYD
-rw-rw---- 1 _mysql wheel 1024 Mar 1 08:13 HourOfDay.MYI
-rw-rw---- 1 _mysql wheel 8598 Mar 1 08:13 HourOfDay.frm
check the database (looks good):
»mysql -u root Mycomp_test -e 'show tables' | grep -i hour
HourOfDay
check the database table (oops wtf!?):
»mysql -u root Mycomp_test -e 'show create table HourOfDay'
ERROR 1146 (42S02) at line 1: Table 'mycomp_test.hourofday' doesn't exist
UPDATE: More info
This is an OSX system running mysql-5.1.38-osx10.5-x86_64
If I drop the database and recreate it I get the same error (it's reliably reproducible).

"Table 'mycomp_test.hourofday' doesn't exist" is suspicious, as it should be HourOFDay on a unix/linux system.

8.2.2. Identifier Case Sensitivity
»cat /etc/my.cnf
[mysqld]
lower_case_table_names=2

Related

How to view error logs generated by mariadb on CentOS 7

I am new to mariadb. Today, I was attempting to import a mysql database to mariadb and during the process the import stops when a warning is encountered as shown below.
Now, I said to myself that I should check a log file so I can see the error but I can't seem to fine any log file. I ran the query below with help from Get the error log of Mariadb:
As you can see there is no path to an error log file.
Next I checked /var/lib/mysql and below is the dir content:
-rw-rw----. 1 mysql mysql 16384 Jun 5 16:03 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Jun 5 16:03 aria_log_control
-rw-rw----. 1 mysql mysql 79691776 Jun 8 08:02 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Jun 8 08:02 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Jun 5 16:03 ib_logfile1
-rw-rw----. 1 mysql mysql 6 Jun 5 16:12 IMSPRO.pid
drwx------. 2 mysql mysql 4096 Jun 8 08:02 ecommence
-rw-rw----. 1 mysql mysql 0 Jun 5 16:12 multi-master.info
drwx--x--x. 2 mysql mysql 4096 Jun 5 16:03 mysql
srwxrwxrwx. 1 mysql mysql 0 Jun 5 16:12 mysql.sock
drwx------. 2 mysql mysql 20 Jun 5 16:03 performance_schema
-rw-rw----. 1 mysql mysql 24576 Jun 5 16:12 tc.log
No file in the above dir logs error.
Below is the content of my /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
Below is the content of /etc/my.cnf.d
drwxr-xr-x. 2 root root 117 Jun 5 16:02 .
drwxr-xr-x. 91 root root 8192 Jun 7 01:14 ..
-rw-r--r--. 1 root root 295 May 29 16:48 client.cnf
-rw-r--r--. 1 root root 763 May 29 16:48 enable_encryption.preset
-rw-r--r--. 1 root root 232 May 29 16:48 mysql-clients.cnf
-rw-r--r--. 1 root root 1080 May 29 16:48 server.cnf
-rw-r--r--. 1 root root 285 May 29 16:48 tokudb.cnf
What can I do to get error log?
The way to see the warnings is to type this immediately after receiving that "Warnings: 1":
SHOW WARNINGS;
(As soon as the next other command is run, the warnings are cleared.)
In mariadb version 10.3.29,
#show variables like 'log-error';
is showing "Empty set" output
Instead, the following command is working
show global variables like 'log_error';
In my case, I edited /etc/my.cnf and added the line log_error after [mysqld]:
[mysqld]
...
log_error
After that, the query show variables like 'log_error'; displays the following (before the change, the Value column was empty):
+---------------+--------------------------+
| Variable_name | Value |
+---------------+--------------------------+
| log_error | /var/lib/mysql/host.err |
+---------------+--------------------------+
Now the error log is being written to the above file.
The exact name of the file will vary from server to server and will take the name of the current host, so expect it to be different in your particular case.

Error bash: syntax error near unexpected toekn 'do' compiling tables

currently using the following guide to create a private server
http://arcemuwiki.blogspot.dk/2012/10/contents-how-to-compile-arcemu-with.html
I get to this step in the guide and when i run:
for table in $(mysql -u root --password=mypass mydb -e "show tables;"); do mysql -u root --password=mypass mydb -e "DROP TABLE $table;"; done;
I get the error:
Error bash: syntax error near unexpected toekn 'do' compiling tables
I have not been able to solve this :/ all help will be appreciated.
Creating the arc_logon, arc_characters and arc_world database structure
Return now to the Arcemu code directory where the base SQL structure files are located.
cd /home/arcemu/src/code/sql
ubuntu#ubuntu:/home/arcemu/src/code/sql$ ls -l
total 480
-rw-r--r-- 1 arcemu arcemu 2146 2011-05-12 22:03 2834_logon_structure.sql
-rw-r--r-- 1 arcemu arcemu 36315 2011-05-12 22:03 3800_character_structure.sql
-rw-r--r-- 1 arcemu arcemu 421549 2011-05-12 22:03 3955_world_structure.sql
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 character_updates
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 extra_scripts
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 logon_updates
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 misc
drwxr-xr-x 4 arcemu arcemu 4096 2011-05-12 22:03 utilities
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 world_updates
ubuntu#ubuntu:/home/arcemu/src/code/sql$
NOTE
In order to drop all of the tables in the database (clear all db), use the following CLI command. WARNING! This will delete your entire database!
for table in $(mysql -u root --password=mypass mydb -e "show tables;"); do mysql -u root --password=mypass mydb -e "DROP TABLE $table;"; done;
Alright nevermind, i solved this problem; however, now I am getting an sql error where it says:
ERROR 1049 (42000): Uknown database 'mydb'
I think where my confusion lies is that in the guide it has me create 3 databases: arc_logon, arc_characters, and arc_world.
Then it has me just the files in the sql folder and I really dont understand what I am trying to do with this for loop. Previously I had believed it was just a note and tried to go to the next step.
The next step is as follows:
Add a users to the arc_logon
Before any users can enter the game, they must have a username and password. The user privileges can be specified (user, GM, etc).
First, add the admin account;
mysql -u root -p arc_logon
type the following.... INSERT INTO accounts (login, password, gm, flags, banned) VALUES ('your-login-name', 'your-password', 'az', '24', '0');
However, when i try to to INSERT INTO line, i get the error that there is not table called accounts; therefore, I was assuming I had to create the table using this for loop for some reason.

Table doesn't exist MySQL

In regards to this guide for compiling Arcemu:
I have followed all steps and everything is fine until I reach the steps:
At the command line, enter the following commands;
create database arc_logon;
create database arc_characters;
create database arc_world;
This isn't the exact spot but shortly after the guide asks me to:
mysql -u root -p arc_logon
INSERT INTO `accounts` (login, password, gm, flags, banned) VALUES ('your-login-name', 'your-password', 'az', '24', '0');
This is right after the following step:
ubuntu#ubuntu:/home/arcemu/src/code/sql$ ls -l
total 480
-rw-r--r-- 1 arcemu arcemu 2146 2011-05-12 22:03 2834_logon_structure.sql
-rw-r--r-- 1 arcemu arcemu 36315 2011-05-12 22:03 3800_character_structure.sql
-rw-r--r-- 1 arcemu arcemu 421549 2011-05-12 22:03 3955_world_structure.sql
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 character_updates
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 extra_scripts
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 logon_updates
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 misc
drwxr-xr-x 4 arcemu arcemu 4096 2011-05-12 22:03 utilities
drwxr-xr-x 3 arcemu arcemu 4096 2011-05-12 22:03 world_updates
After executing the INSERT INTO line of code I receive the error:
Error 1146 (42502): Table 'arc_logon.accounts' doesn't exist
Why is there no accounts table populated when I created the database? Do I have to set it up?
Open nautilus (file explorer) and navigate to:
/home/arcemu/src/code/sql
Make sure all these files exist there:
logon_structure.sql,
character_structure.sql,
world_structure.sql
Now, in your terminal, do:
cd /home/arcemu/src/code/sql
Then, import each of the above files, do:
mysql -u root -p arc_logon < logon_structure.sql
mysql -u root -p arc_character < character_structure.sql
mysql -u root -p arc_world < world_structure.sql
You will be asked to enter the mysql password after each one.
Try to do this
first open a connection to mysql
mysql -u root -p -h localhost
after successfully logging in
execute
USE arc_logon;
SHOW TABLES;
This will give you a list of all tables in arc_logon. If you can find the 'accounts' table then you should run the query and it will work
USE arc_logon;
INSERT INTO `accounts` (login, password, gm, flags, banned) VALUES ('your-login-name', 'your-password', 'az', '24', '0');
Or you can also do this
SELECT * FROM information_schema.tables where table_schema = 'arc_logon' AND table_name= 'accounts'
If the above query return a single row, then the insert should work otherwise create the accounts table as it does not exists in this database.

how to import .opt .frm .myd ,mid files to MySQL?

I have a data base that includes one file .opt and a three files .frm .mid .myd for each entity in this DB.
can anyone help me with importing this data base to mySql?
Thanks
Do you mean .MYI instead of *.MID.
Filename with extensions .FRM .MYD .MYI in MySQL are MyISAM Tables. You can just simply copy these files into database folder.
mysql> create database myDatabase;
Query OK, 1 row affected (0.00 sec)
mysql> quit
Bye
[root#venus cart]# ls tt*.*
tt.frm tt.MYD tt.MYI
[root#venus cart]# cp tt.* /var/lib/mysql/myDatabase/
[root#venus cart]#
[root#venus cart]#
[root#venus cart]# cd /var/lib/mysql/myDatabase/
[root#venus myDatabase]# ll
total 24
-rw-rw----. 1 mysql mysql 65 Apr 15 10:36 db.opt
-rw-r-----. 1 root root 8582 Apr 15 10:37 tt.frm
-rw-r-----. 1 root root 18 Apr 15 10:37 tt.MYD
-rw-r-----. 1 root root 3072 Apr 15 10:37 tt.MYI
[root#venus myDatabase]# chown mysql.mysql tt.*
[root#venus myDatabase]# ll
total 24
-rw-rw----. 1 mysql mysql 65 Apr 15 10:36 db.opt
-rw-r-----. 1 mysql mysql 8582 Apr 15 10:37 tt.frm
-rw-r-----. 1 mysql mysql 18 Apr 15 10:37 tt.MYD
-rw-r-----. 1 mysql mysql 3072 Apr 15 10:37 tt.MYI
[root#venus myDatabase]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use myDatabase;
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> SELECT * FROM tt;
+----+------+
| id | c1 |
+----+------+
| 2 | 3 |
| 3 | 2 |
+----+------+
2 rows in set (0.00 sec)

how to access a database files via the command line mysql?

I just installed mysql for the first time and created a databse with create database foo;
I think I have found where mysql stores the databases (/var/lib/mysql). When I try to cd to the foo directory I get permission denied. When I try with sudo nothing happens.
output of ls -l
-rw-rw----. 1 mysql mysql 16384 Feb 21 17:44 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Feb 21 17:44 aria_log_control
drwx------. 2 mysql mysql 4096 Mar 1 22:08 foo
-rw-rw----. 1 mysql mysql 18874368 Feb 21 17:44 ibdata1
-rw-rw----. 1 mysql mysql 5242880 Mar 1 16:05 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 Feb 21 17:34 ib_logfile1
drwx------. 2 mysql mysql 4096 Feb 21 17:34 mysql
srwxrwxrwx. 1 mysql mysql 0 Mar 1 16:05 mysql.sock
drwx------. 2 mysql mysql 4096 Feb 21 17:34 performance_schema
I know your meant to view the databases and stuff through that application on the command line but I am interested as to why I can't view the foo directory when i am root.
You can't view the foo directory because of the permissions:
owner - mysql - read, write, execute
group - mysql - no access
other - no access
First connect to mysql from command prompt using
[root#host]# mysql -u root -p
Enter password:******
Now select the database using
mysql> USE DB_Name
You can use belo command to have the list of databases
mysql> SHOW DATABASES;
To get the directory details you can use
mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name = "dir_name"